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 2022/07/01 19:30:31 UTC

[arrow-datafusion] branch master updated: Update to arrow 17.0.0 (#2778)

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


The following commit(s) were added to refs/heads/master by this push:
     new 85ca8be66 Update to arrow 17.0.0 (#2778)
85ca8be66 is described below

commit 85ca8be669dc1fbba4b2eefbf99fc2ed1546cc0c
Author: Andrew Lamb <an...@nerdnetworks.org>
AuthorDate: Fri Jul 1 15:30:25 2022 -0400

    Update to arrow 17.0.0 (#2778)
    
    * Update to arrow 17.0.0
    
    * Update for change in Decimal interface
---
 datafusion-cli/Cargo.toml                          |   2 +-
 datafusion-examples/Cargo.toml                     |   2 +-
 datafusion/common/Cargo.toml                       |   4 +-
 datafusion/common/src/scalar.rs                    |  13 ++-
 datafusion/core/Cargo.toml                         |   4 +-
 datafusion/core/fuzz-utils/Cargo.toml              |   2 +-
 datafusion/core/src/physical_plan/hash_utils.rs    |  16 ++--
 datafusion/core/src/scalar.rs                      |   6 +-
 datafusion/expr/Cargo.toml                         |   2 +-
 datafusion/jit/Cargo.toml                          |   2 +-
 datafusion/optimizer/Cargo.toml                    |   2 +-
 datafusion/physical-expr/Cargo.toml                |   2 +-
 datafusion/physical-expr/src/aggregate/min_max.rs  |   6 +-
 datafusion/physical-expr/src/aggregate/sum.rs      |   2 +-
 datafusion/physical-expr/src/expressions/cast.rs   | 102 ++++++++++++---------
 .../physical-expr/src/expressions/try_cast.rs      | 100 +++++++++++---------
 datafusion/proto/Cargo.toml                        |   2 +-
 datafusion/row/Cargo.toml                          |   2 +-
 datafusion/sql/Cargo.toml                          |   2 +-
 19 files changed, 154 insertions(+), 119 deletions(-)

diff --git a/datafusion-cli/Cargo.toml b/datafusion-cli/Cargo.toml
index a3f67368b..b7755b3d9 100644
--- a/datafusion-cli/Cargo.toml
+++ b/datafusion-cli/Cargo.toml
@@ -29,7 +29,7 @@ rust-version = "1.59"
 readme = "README.md"
 
 [dependencies]
-arrow = { version = "16.0.0" }
+arrow = { version = "17.0.0" }
 clap = { version = "3", features = ["derive", "cargo"] }
 datafusion = { path = "../datafusion/core", version = "9.0.0" }
 dirs = "4.0.0"
diff --git a/datafusion-examples/Cargo.toml b/datafusion-examples/Cargo.toml
index 708cc3cc4..44c40d455 100644
--- a/datafusion-examples/Cargo.toml
+++ b/datafusion-examples/Cargo.toml
@@ -34,7 +34,7 @@ path = "examples/avro_sql.rs"
 required-features = ["datafusion/avro"]
 
 [dev-dependencies]
-arrow-flight = { version = "16.0.0" }
+arrow-flight = { version = "17.0.0" }
 async-trait = "0.1.41"
 datafusion = { path = "../datafusion/core" }
 futures = "0.3"
diff --git a/datafusion/common/Cargo.toml b/datafusion/common/Cargo.toml
index 1589c5481..367a8fb70 100644
--- a/datafusion/common/Cargo.toml
+++ b/datafusion/common/Cargo.toml
@@ -38,10 +38,10 @@ jit = ["cranelift-module"]
 pyarrow = ["pyo3"]
 
 [dependencies]
-arrow = { version = "16.0.0", features = ["prettyprint"] }
+arrow = { version = "17.0.0", features = ["prettyprint"] }
 avro-rs = { version = "0.13", features = ["snappy"], optional = true }
 cranelift-module = { version = "0.85.0", optional = true }
 ordered-float = "3.0"
-parquet = { version = "16.0.0", features = ["arrow"], optional = true }
+parquet = { version = "17.0.0", features = ["arrow"], optional = true }
 pyo3 = { version = "0.16", optional = true }
 sqlparser = "0.18"
diff --git a/datafusion/common/src/scalar.rs b/datafusion/common/src/scalar.rs
index db7fedeb2..f21a6e605 100644
--- a/datafusion/common/src/scalar.rs
+++ b/datafusion/common/src/scalar.rs
@@ -28,6 +28,7 @@ use arrow::{
         TimestampSecondType, UInt16Type, UInt32Type, UInt64Type, UInt8Type,
         DECIMAL_MAX_PRECISION,
     },
+    util::decimal::{BasicDecimal, Decimal128},
 };
 use ordered_float::OrderedFloat;
 use std::cmp::Ordering;
@@ -1275,7 +1276,11 @@ impl ScalarValue {
         if array.is_null(index) {
             ScalarValue::Decimal128(None, *precision, *scale)
         } else {
-            ScalarValue::Decimal128(Some(array.value(index)), *precision, *scale)
+            ScalarValue::Decimal128(
+                Some(array.value(index).as_i128()),
+                *precision,
+                *scale,
+            )
         }
     }
 
@@ -1450,7 +1455,11 @@ impl ScalarValue {
         }
         match value {
             None => array.is_null(index),
-            Some(v) => !array.is_null(index) && array.value(index) == *v,
+            Some(v) => {
+                !array.is_null(index)
+                    && array.value(index)
+                        == Decimal128::new(precision, scale, &v.to_le_bytes())
+            }
         }
     }
 
diff --git a/datafusion/core/Cargo.toml b/datafusion/core/Cargo.toml
index f45b4eb26..af49d862f 100644
--- a/datafusion/core/Cargo.toml
+++ b/datafusion/core/Cargo.toml
@@ -55,7 +55,7 @@ unicode_expressions = ["datafusion-physical-expr/regex_expressions", "datafusion
 
 [dependencies]
 ahash = { version = "0.7", default-features = false }
-arrow = { version = "16.0.0", features = ["prettyprint"] }
+arrow = { version = "17.0.0", features = ["prettyprint"] }
 async-trait = "0.1.41"
 avro-rs = { version = "0.13", features = ["snappy"], optional = true }
 chrono = { version = "0.4", default-features = false }
@@ -77,7 +77,7 @@ num-traits = { version = "0.2", optional = true }
 num_cpus = "1.13.0"
 ordered-float = "3.0"
 parking_lot = "0.12"
-parquet = { version = "16.0.0", features = ["arrow"] }
+parquet = { version = "17.0.0", features = ["arrow"] }
 paste = "^1.0"
 pin-project-lite = "^0.2.7"
 pyo3 = { version = "0.16", optional = true }
diff --git a/datafusion/core/fuzz-utils/Cargo.toml b/datafusion/core/fuzz-utils/Cargo.toml
index 4366e3332..1cc8a60e7 100644
--- a/datafusion/core/fuzz-utils/Cargo.toml
+++ b/datafusion/core/fuzz-utils/Cargo.toml
@@ -23,6 +23,6 @@ edition = "2021"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-arrow = { version = "16.0.0", features = ["prettyprint"] }
+arrow = { version = "17.0.0", features = ["prettyprint"] }
 env_logger = "0.9.0"
 rand = "0.8"
diff --git a/datafusion/core/src/physical_plan/hash_utils.rs b/datafusion/core/src/physical_plan/hash_utils.rs
index 92598afbd..79fdcf99c 100644
--- a/datafusion/core/src/physical_plan/hash_utils.rs
+++ b/datafusion/core/src/physical_plan/hash_utils.rs
@@ -62,25 +62,29 @@ fn hash_decimal128<'a>(
     if array.null_count() == 0 {
         if mul_col {
             for (i, hash) in hashes_buffer.iter_mut().enumerate() {
-                *hash =
-                    combine_hashes(i128::get_hash(&array.value(i), random_state), *hash);
+                *hash = combine_hashes(
+                    i128::get_hash(&array.value(i).as_i128(), random_state),
+                    *hash,
+                );
             }
         } else {
             for (i, hash) in hashes_buffer.iter_mut().enumerate() {
-                *hash = i128::get_hash(&array.value(i), random_state);
+                *hash = i128::get_hash(&array.value(i).as_i128(), random_state);
             }
         }
     } else if mul_col {
         for (i, hash) in hashes_buffer.iter_mut().enumerate() {
             if !array.is_null(i) {
-                *hash =
-                    combine_hashes(i128::get_hash(&array.value(i), random_state), *hash);
+                *hash = combine_hashes(
+                    i128::get_hash(&array.value(i).as_i128(), random_state),
+                    *hash,
+                );
             }
         }
     } else {
         for (i, hash) in hashes_buffer.iter_mut().enumerate() {
             if !array.is_null(i) {
-                *hash = i128::get_hash(&array.value(i), random_state);
+                *hash = i128::get_hash(&array.value(i).as_i128(), random_state);
             }
         }
     }
diff --git a/datafusion/core/src/scalar.rs b/datafusion/core/src/scalar.rs
index 7ec8c53a8..97b4663f9 100644
--- a/datafusion/core/src/scalar.rs
+++ b/datafusion/core/src/scalar.rs
@@ -49,15 +49,15 @@ mod tests {
         let array = array.as_any().downcast_ref::<DecimalArray>().unwrap();
         assert_eq!(1, array.len());
         assert_eq!(DataType::Decimal(10, 1), array.data_type().clone());
-        assert_eq!(123i128, array.value(0));
+        assert_eq!(123i128, array.value(0).as_i128());
 
         // decimal scalar to array with size
         let array = decimal_value.to_array_of_size(10);
         let array_decimal = array.as_any().downcast_ref::<DecimalArray>().unwrap();
         assert_eq!(10, array.len());
         assert_eq!(DataType::Decimal(10, 1), array.data_type().clone());
-        assert_eq!(123i128, array_decimal.value(0));
-        assert_eq!(123i128, array_decimal.value(9));
+        assert_eq!(123i128, array_decimal.value(0).as_i128());
+        assert_eq!(123i128, array_decimal.value(9).as_i128());
         // test eq array
         assert!(decimal_value.eq_array(&array, 1));
         assert!(decimal_value.eq_array(&array, 5));
diff --git a/datafusion/expr/Cargo.toml b/datafusion/expr/Cargo.toml
index 228fd1ed9..4f8f1e01a 100644
--- a/datafusion/expr/Cargo.toml
+++ b/datafusion/expr/Cargo.toml
@@ -36,6 +36,6 @@ path = "src/lib.rs"
 
 [dependencies]
 ahash = { version = "0.7", default-features = false }
-arrow = { version = "16.0.0", features = ["prettyprint"] }
+arrow = { version = "17.0.0", features = ["prettyprint"] }
 datafusion-common = { path = "../common", version = "9.0.0" }
 sqlparser = "0.18"
diff --git a/datafusion/jit/Cargo.toml b/datafusion/jit/Cargo.toml
index 60c3aa588..8ffdf266c 100644
--- a/datafusion/jit/Cargo.toml
+++ b/datafusion/jit/Cargo.toml
@@ -36,7 +36,7 @@ path = "src/lib.rs"
 jit = []
 
 [dependencies]
-arrow = { version = "16.0.0" }
+arrow = { version = "17.0.0" }
 cranelift = "0.85.0"
 cranelift-jit = "0.85.0"
 cranelift-module = "0.85.0"
diff --git a/datafusion/optimizer/Cargo.toml b/datafusion/optimizer/Cargo.toml
index 4bd386879..1104cbe81 100644
--- a/datafusion/optimizer/Cargo.toml
+++ b/datafusion/optimizer/Cargo.toml
@@ -37,7 +37,7 @@ default = ["unicode_expressions"]
 unicode_expressions = []
 
 [dependencies]
-arrow = { version = "16.0.0", features = ["prettyprint"] }
+arrow = { version = "17.0.0", features = ["prettyprint"] }
 async-trait = "0.1.41"
 chrono = { version = "0.4", default-features = false }
 datafusion-common = { path = "../common", version = "9.0.0" }
diff --git a/datafusion/physical-expr/Cargo.toml b/datafusion/physical-expr/Cargo.toml
index 1bb05387b..41a16f21c 100644
--- a/datafusion/physical-expr/Cargo.toml
+++ b/datafusion/physical-expr/Cargo.toml
@@ -40,7 +40,7 @@ unicode_expressions = ["unicode-segmentation"]
 
 [dependencies]
 ahash = { version = "0.7", default-features = false }
-arrow = { version = "16.0.0", features = ["prettyprint"] }
+arrow = { version = "17.0.0", features = ["prettyprint"] }
 blake2 = { version = "^0.10.2", optional = true }
 blake3 = { version = "1.0", optional = true }
 chrono = { version = "0.4", default-features = false }
diff --git a/datafusion/physical-expr/src/aggregate/min_max.rs b/datafusion/physical-expr/src/aggregate/min_max.rs
index dd2f44b22..37df7713e 100644
--- a/datafusion/physical-expr/src/aggregate/min_max.rs
+++ b/datafusion/physical-expr/src/aggregate/min_max.rs
@@ -182,17 +182,17 @@ macro_rules! typed_min_max_batch_decimal128 {
                 for i in 1..array.len() {
                     result = result.$OP(array.value(i));
                 }
-                ScalarValue::Decimal128(Some(result), *$PRECISION, *$SCALE)
+                ScalarValue::Decimal128(Some(result.as_i128()), *$PRECISION, *$SCALE)
             } else {
                 let mut result = 0_i128;
                 let mut has_value = false;
                 for i in 0..array.len() {
                     if !has_value && array.is_valid(i) {
                         has_value = true;
-                        result = array.value(i);
+                        result = array.value(i).as_i128();
                     }
                     if array.is_valid(i) {
-                        result = result.$OP(array.value(i));
+                        result = result.$OP(array.value(i).as_i128());
                     }
                 }
                 ScalarValue::Decimal128(Some(result), *$PRECISION, *$SCALE)
diff --git a/datafusion/physical-expr/src/aggregate/sum.rs b/datafusion/physical-expr/src/aggregate/sum.rs
index c369e7af0..056af7747 100644
--- a/datafusion/physical-expr/src/aggregate/sum.rs
+++ b/datafusion/physical-expr/src/aggregate/sum.rs
@@ -166,7 +166,7 @@ fn sum_decimal_batch(
     let mut result = 0_i128;
     for i in 0..array.len() {
         if array.is_valid(i) {
-            result += array.value(i);
+            result += array.value(i).as_i128();
         }
     }
     Ok(ScalarValue::Decimal128(Some(result), *precision, *scale))
diff --git a/datafusion/physical-expr/src/expressions/cast.rs b/datafusion/physical-expr/src/expressions/cast.rs
index a373685c7..0108f7fee 100644
--- a/datafusion/physical-expr/src/expressions/cast.rs
+++ b/datafusion/physical-expr/src/expressions/cast.rs
@@ -166,6 +166,7 @@ mod tests {
             TimestampNanosecondArray, UInt32Array,
         },
         datatypes::*,
+        util::decimal::{BasicDecimal, Decimal128},
     };
     use datafusion_common::Result;
 
@@ -278,17 +279,20 @@ mod tests {
             .collect::<DecimalArray>()
             .with_precision_and_scale(10, 3)?;
 
+        // closure that converts to i128
+        let convert = |v: i128| Decimal128::new(20, 6, &v.to_le_bytes());
+
         generic_decimal_to_other_test_cast!(
             decimal_array,
             DataType::Decimal(10, 3),
             DecimalArray,
             DataType::Decimal(20, 6),
             vec![
-                Some(1_234_000_i128),
-                Some(2_222_000_i128),
-                Some(3_000_i128),
-                Some(4_000_000_i128),
-                Some(5_000_000_i128),
+                Some(convert(1_234_000)),
+                Some(convert(2_222_000)),
+                Some(convert(3_000)),
+                Some(convert(4_000_000)),
+                Some(convert(5_000_000)),
                 None,
             ],
             DEFAULT_DATAFUSION_CAST_OPTIONS
@@ -300,17 +304,18 @@ mod tests {
             .collect::<DecimalArray>()
             .with_precision_and_scale(10, 3)?;
 
+        let convert = |v: i128| Decimal128::new(10, 2, &v.to_le_bytes());
         generic_decimal_to_other_test_cast!(
             decimal_array,
             DataType::Decimal(10, 3),
             DecimalArray,
             DataType::Decimal(10, 2),
             vec![
-                Some(123_i128),
-                Some(222_i128),
-                Some(0_i128),
-                Some(400_i128),
-                Some(500_i128),
+                Some(convert(123)),
+                Some(convert(222)),
+                Some(convert(0)),
+                Some(convert(400)),
+                Some(convert(500)),
                 None,
             ],
             DEFAULT_DATAFUSION_CAST_OPTIONS
@@ -461,6 +466,7 @@ mod tests {
     #[test]
     fn test_cast_numeric_to_decimal() -> Result<()> {
         // int8
+        let convert = |v: i128| Decimal128::new(3, 0, &v.to_le_bytes());
         generic_test_cast!(
             Int8Array,
             DataType::Int8,
@@ -468,16 +474,17 @@ mod tests {
             DecimalArray,
             DataType::Decimal(3, 0),
             vec![
-                Some(1_i128),
-                Some(2_i128),
-                Some(3_i128),
-                Some(4_i128),
-                Some(5_i128),
+                Some(convert(1)),
+                Some(convert(2)),
+                Some(convert(3)),
+                Some(convert(4)),
+                Some(convert(5)),
             ],
             DEFAULT_DATAFUSION_CAST_OPTIONS
         );
 
         // int16
+        let convert = |v: i128| Decimal128::new(5, 0, &v.to_le_bytes());
         generic_test_cast!(
             Int16Array,
             DataType::Int16,
@@ -485,16 +492,17 @@ mod tests {
             DecimalArray,
             DataType::Decimal(5, 0),
             vec![
-                Some(1_i128),
-                Some(2_i128),
-                Some(3_i128),
-                Some(4_i128),
-                Some(5_i128),
+                Some(convert(1)),
+                Some(convert(2)),
+                Some(convert(3)),
+                Some(convert(4)),
+                Some(convert(5)),
             ],
             DEFAULT_DATAFUSION_CAST_OPTIONS
         );
 
         // int32
+        let convert = |v: i128| Decimal128::new(10, 0, &v.to_le_bytes());
         generic_test_cast!(
             Int32Array,
             DataType::Int32,
@@ -502,16 +510,17 @@ mod tests {
             DecimalArray,
             DataType::Decimal(10, 0),
             vec![
-                Some(1_i128),
-                Some(2_i128),
-                Some(3_i128),
-                Some(4_i128),
-                Some(5_i128),
+                Some(convert(1)),
+                Some(convert(2)),
+                Some(convert(3)),
+                Some(convert(4)),
+                Some(convert(5)),
             ],
             DEFAULT_DATAFUSION_CAST_OPTIONS
         );
 
         // int64
+        let convert = |v: i128| Decimal128::new(20, 0, &v.to_le_bytes());
         generic_test_cast!(
             Int64Array,
             DataType::Int64,
@@ -519,16 +528,17 @@ mod tests {
             DecimalArray,
             DataType::Decimal(20, 0),
             vec![
-                Some(1_i128),
-                Some(2_i128),
-                Some(3_i128),
-                Some(4_i128),
-                Some(5_i128),
+                Some(convert(1)),
+                Some(convert(2)),
+                Some(convert(3)),
+                Some(convert(4)),
+                Some(convert(5)),
             ],
             DEFAULT_DATAFUSION_CAST_OPTIONS
         );
 
         // int64 to different scale
+        let convert = |v: i128| Decimal128::new(20, 2, &v.to_le_bytes());
         generic_test_cast!(
             Int64Array,
             DataType::Int64,
@@ -536,16 +546,17 @@ mod tests {
             DecimalArray,
             DataType::Decimal(20, 2),
             vec![
-                Some(100_i128),
-                Some(200_i128),
-                Some(300_i128),
-                Some(400_i128),
-                Some(500_i128),
+                Some(convert(100)),
+                Some(convert(200)),
+                Some(convert(300)),
+                Some(convert(400)),
+                Some(convert(500)),
             ],
             DEFAULT_DATAFUSION_CAST_OPTIONS
         );
 
         // float32
+        let convert = |v: i128| Decimal128::new(10, 2, &v.to_le_bytes());
         generic_test_cast!(
             Float32Array,
             DataType::Float32,
@@ -553,16 +564,17 @@ mod tests {
             DecimalArray,
             DataType::Decimal(10, 2),
             vec![
-                Some(150_i128),
-                Some(250_i128),
-                Some(300_i128),
-                Some(112_i128),
-                Some(550_i128),
+                Some(convert(150)),
+                Some(convert(250)),
+                Some(convert(300)),
+                Some(convert(112)),
+                Some(convert(550)),
             ],
             DEFAULT_DATAFUSION_CAST_OPTIONS
         );
 
         // float64
+        let convert = |v: i128| Decimal128::new(20, 4, &v.to_le_bytes());
         generic_test_cast!(
             Float64Array,
             DataType::Float64,
@@ -570,11 +582,11 @@ mod tests {
             DecimalArray,
             DataType::Decimal(20, 4),
             vec![
-                Some(15000_i128),
-                Some(25000_i128),
-                Some(30000_i128),
-                Some(11234_i128),
-                Some(55000_i128),
+                Some(convert(15000)),
+                Some(convert(25000)),
+                Some(convert(30000)),
+                Some(convert(11234)),
+                Some(convert(55000)),
             ],
             DEFAULT_DATAFUSION_CAST_OPTIONS
         );
diff --git a/datafusion/physical-expr/src/expressions/try_cast.rs b/datafusion/physical-expr/src/expressions/try_cast.rs
index 53e1d3e89..c5178b4db 100644
--- a/datafusion/physical-expr/src/expressions/try_cast.rs
+++ b/datafusion/physical-expr/src/expressions/try_cast.rs
@@ -121,6 +121,7 @@ mod tests {
     use arrow::array::{
         DecimalArray, DecimalBuilder, StringArray, Time64NanosecondArray,
     };
+    use arrow::util::decimal::{BasicDecimal, Decimal128};
     use arrow::{
         array::{
             Array, Float32Array, Float64Array, Int16Array, Int32Array, Int64Array,
@@ -232,33 +233,35 @@ mod tests {
         // try cast one decimal data type to another decimal data type
         let array: Vec<i128> = vec![1234, 2222, 3, 4000, 5000];
         let decimal_array = create_decimal_array(&array, 10, 3)?;
+        let convert = |v: i128| Decimal128::new(20, 6, &v.to_le_bytes());
         generic_decimal_to_other_test_cast!(
             decimal_array,
             DataType::Decimal(10, 3),
             DecimalArray,
             DataType::Decimal(20, 6),
             vec![
-                Some(1_234_000_i128),
-                Some(2_222_000_i128),
-                Some(3_000_i128),
-                Some(4_000_000_i128),
-                Some(5_000_000_i128),
+                Some(convert(1_234_000)),
+                Some(convert(2_222_000)),
+                Some(convert(3_000)),
+                Some(convert(4_000_000)),
+                Some(convert(5_000_000)),
                 None,
             ]
         );
 
         let decimal_array = create_decimal_array(&array, 10, 3)?;
+        let convert = |v: i128| Decimal128::new(10, 2, &v.to_le_bytes());
         generic_decimal_to_other_test_cast!(
             decimal_array,
             DataType::Decimal(10, 3),
             DecimalArray,
             DataType::Decimal(10, 2),
             vec![
-                Some(123_i128),
-                Some(222_i128),
-                Some(0_i128),
-                Some(400_i128),
-                Some(500_i128),
+                Some(convert(123)),
+                Some(convert(222)),
+                Some(convert(0)),
+                Some(convert(400)),
+                Some(convert(500)),
                 None,
             ]
         );
@@ -379,6 +382,7 @@ mod tests {
     #[test]
     fn test_try_cast_numeric_to_decimal() -> Result<()> {
         // int8
+        let convert = |v: i128| Decimal128::new(3, 0, &v.to_le_bytes());
         generic_test_cast!(
             Int8Array,
             DataType::Int8,
@@ -386,15 +390,16 @@ mod tests {
             DecimalArray,
             DataType::Decimal(3, 0),
             vec![
-                Some(1_i128),
-                Some(2_i128),
-                Some(3_i128),
-                Some(4_i128),
-                Some(5_i128),
+                Some(convert(1)),
+                Some(convert(2)),
+                Some(convert(3)),
+                Some(convert(4)),
+                Some(convert(5)),
             ]
         );
 
         // int16
+        let convert = |v: i128| Decimal128::new(5, 0, &v.to_le_bytes());
         generic_test_cast!(
             Int16Array,
             DataType::Int16,
@@ -402,15 +407,16 @@ mod tests {
             DecimalArray,
             DataType::Decimal(5, 0),
             vec![
-                Some(1_i128),
-                Some(2_i128),
-                Some(3_i128),
-                Some(4_i128),
-                Some(5_i128),
+                Some(convert(1)),
+                Some(convert(2)),
+                Some(convert(3)),
+                Some(convert(4)),
+                Some(convert(5)),
             ]
         );
 
         // int32
+        let convert = |v: i128| Decimal128::new(10, 0, &v.to_le_bytes());
         generic_test_cast!(
             Int32Array,
             DataType::Int32,
@@ -418,15 +424,16 @@ mod tests {
             DecimalArray,
             DataType::Decimal(10, 0),
             vec![
-                Some(1_i128),
-                Some(2_i128),
-                Some(3_i128),
-                Some(4_i128),
-                Some(5_i128),
+                Some(convert(1)),
+                Some(convert(2)),
+                Some(convert(3)),
+                Some(convert(4)),
+                Some(convert(5)),
             ]
         );
 
         // int64
+        let convert = |v: i128| Decimal128::new(20, 0, &v.to_le_bytes());
         generic_test_cast!(
             Int64Array,
             DataType::Int64,
@@ -434,15 +441,16 @@ mod tests {
             DecimalArray,
             DataType::Decimal(20, 0),
             vec![
-                Some(1_i128),
-                Some(2_i128),
-                Some(3_i128),
-                Some(4_i128),
-                Some(5_i128),
+                Some(convert(1)),
+                Some(convert(2)),
+                Some(convert(3)),
+                Some(convert(4)),
+                Some(convert(5)),
             ]
         );
 
         // int64 to different scale
+        let convert = |v: i128| Decimal128::new(20, 2, &v.to_le_bytes());
         generic_test_cast!(
             Int64Array,
             DataType::Int64,
@@ -450,15 +458,16 @@ mod tests {
             DecimalArray,
             DataType::Decimal(20, 2),
             vec![
-                Some(100_i128),
-                Some(200_i128),
-                Some(300_i128),
-                Some(400_i128),
-                Some(500_i128),
+                Some(convert(100)),
+                Some(convert(200)),
+                Some(convert(300)),
+                Some(convert(400)),
+                Some(convert(500)),
             ]
         );
 
         // float32
+        let convert = |v: i128| Decimal128::new(10, 2, &v.to_le_bytes());
         generic_test_cast!(
             Float32Array,
             DataType::Float32,
@@ -466,15 +475,16 @@ mod tests {
             DecimalArray,
             DataType::Decimal(10, 2),
             vec![
-                Some(150_i128),
-                Some(250_i128),
-                Some(300_i128),
-                Some(112_i128),
-                Some(550_i128),
+                Some(convert(150)),
+                Some(convert(250)),
+                Some(convert(300)),
+                Some(convert(112)),
+                Some(convert(550)),
             ]
         );
 
         // float64
+        let convert = |v: i128| Decimal128::new(20, 4, &v.to_le_bytes());
         generic_test_cast!(
             Float64Array,
             DataType::Float64,
@@ -482,11 +492,11 @@ mod tests {
             DecimalArray,
             DataType::Decimal(20, 4),
             vec![
-                Some(15000_i128),
-                Some(25000_i128),
-                Some(30000_i128),
-                Some(11234_i128),
-                Some(55000_i128),
+                Some(convert(15000)),
+                Some(convert(25000)),
+                Some(convert(30000)),
+                Some(convert(11234)),
+                Some(convert(55000)),
             ]
         );
         Ok(())
diff --git a/datafusion/proto/Cargo.toml b/datafusion/proto/Cargo.toml
index d159e9e79..d4ee90101 100644
--- a/datafusion/proto/Cargo.toml
+++ b/datafusion/proto/Cargo.toml
@@ -35,7 +35,7 @@ path = "src/lib.rs"
 [features]
 
 [dependencies]
-arrow = { version = "16.0.0" }
+arrow = { version = "17.0.0" }
 datafusion = { path = "../core", version = "9.0.0" }
 datafusion-common = { path = "../common", version = "9.0.0" }
 datafusion-expr = { path = "../expr", version = "9.0.0" }
diff --git a/datafusion/row/Cargo.toml b/datafusion/row/Cargo.toml
index 8bb1e6274..0dd07a5e2 100644
--- a/datafusion/row/Cargo.toml
+++ b/datafusion/row/Cargo.toml
@@ -37,7 +37,7 @@ path = "src/lib.rs"
 jit = ["datafusion-jit"]
 
 [dependencies]
-arrow = { version = "16.0.0" }
+arrow = { version = "17.0.0" }
 datafusion-common = { path = "../common", version = "9.0.0" }
 datafusion-jit = { path = "../jit", version = "9.0.0", optional = true }
 paste = "^1.0"
diff --git a/datafusion/sql/Cargo.toml b/datafusion/sql/Cargo.toml
index 42ca5b41c..fa477a0b7 100644
--- a/datafusion/sql/Cargo.toml
+++ b/datafusion/sql/Cargo.toml
@@ -38,7 +38,7 @@ unicode_expressions = []
 
 [dependencies]
 ahash = { version = "0.7", default-features = false }
-arrow = { version = "16.0.0", features = ["prettyprint"] }
+arrow = { version = "17.0.0", features = ["prettyprint"] }
 datafusion-common = { path = "../common", version = "9.0.0" }
 datafusion-expr = { path = "../expr", version = "9.0.0" }
 hashbrown = "0.12"