diff --git a/datafusion/benches/data_utils/mod.rs b/datafusion/benches/data_utils/mod.rs index 7d2885e380ae..ce7bb2b47e64 100644 --- a/datafusion/benches/data_utils/mod.rs +++ b/datafusion/benches/data_utils/mod.rs @@ -123,7 +123,7 @@ fn create_record_batch( schema, vec![ Arc::new(Utf8Array::::from_slice(keys)), - Arc::new(Float32Array::from_slice(vec![i as f32; batch_size])), + Arc::new(Float32Array::from_slice(&[i as f32; batch_size])), Arc::new(Float64Array::from(values)), Arc::new(UInt64Array::from(integer_values_wide)), Arc::new(UInt64Array::from_slice(integer_values_narrow)), diff --git a/datafusion/src/datasource/file_format/parquet.rs b/datafusion/src/datasource/file_format/parquet.rs index 313d6e475ab7..c32f7b2aa9ba 100644 --- a/datafusion/src/datasource/file_format/parquet.rs +++ b/datafusion/src/datasource/file_format/parquet.rs @@ -141,7 +141,7 @@ fn summarize_min_max( if let Some(max_value) = &mut max_values[i] { if let Some(v) = stats.max_value { match max_value.update_batch(&[Arc::new( - arrow::array::$ARRAY_TYPE::from_slice(vec![v]), + arrow::array::$ARRAY_TYPE::from_slice(&[v]), )]) { Ok(_) => {} Err(_) => { @@ -153,7 +153,7 @@ fn summarize_min_max( if let Some(min_value) = &mut min_values[i] { if let Some(v) = stats.min_value { match min_value.update_batch(&[Arc::new( - arrow::array::$ARRAY_TYPE::from_slice(vec![v]), + arrow::array::$ARRAY_TYPE::from_slice(&[v]), )]) { Ok(_) => {} Err(_) => { @@ -180,7 +180,7 @@ fn summarize_min_max( if let Some(max_value) = &mut max_values[i] { if let Some(v) = stats.max_value { match max_value - .update_batch(&[Arc::new(BooleanArray::from_slice(vec![v]))]) + .update_batch(&[Arc::new(BooleanArray::from_slice(&[v]))]) { Ok(_) => {} Err(_) => { @@ -192,7 +192,7 @@ fn summarize_min_max( if let Some(min_value) = &mut min_values[i] { if let Some(v) = stats.min_value { match min_value - .update_batch(&[Arc::new(BooleanArray::from_slice(vec![v]))]) + .update_batch(&[Arc::new(BooleanArray::from_slice(&[v]))]) { Ok(_) => {} Err(_) => { diff --git a/datafusion/src/execution/context.rs b/datafusion/src/execution/context.rs index 9d77ed530789..9aa2b476bc9f 100644 --- a/datafusion/src/execution/context.rs +++ b/datafusion/src/execution/context.rs @@ -3681,8 +3681,8 @@ mod tests { }; // create mock record batch - let ids = Arc::new(Int32Array::from_slice(vec![i as i32])); - let names = Arc::new(Utf8Array::::from_slice(vec!["test"])); + let ids = Arc::new(Int32Array::from_slice(&[i as i32])); + let names = Arc::new(Utf8Array::::from_slice(&["test"])); let schema_ref = schema.as_ref(); let parquet_schema = to_parquet_schema(schema_ref).unwrap(); let iter = vec![Ok(Chunk::new(vec![ids as ArrayRef, names as ArrayRef]))]; diff --git a/datafusion/src/physical_plan/expressions/array_agg.rs b/datafusion/src/physical_plan/expressions/array_agg.rs index be49408bdf16..032ac6f4bd5e 100644 --- a/datafusion/src/physical_plan/expressions/array_agg.rs +++ b/datafusion/src/physical_plan/expressions/array_agg.rs @@ -168,7 +168,7 @@ mod tests { #[test] fn array_agg_i32() -> Result<()> { - let a: ArrayRef = Arc::new(Int32Array::from_slice(vec![1, 2, 3, 4, 5])); + let a: ArrayRef = Arc::new(Int32Array::from_slice(&[1, 2, 3, 4, 5])); let list = ScalarValue::List( Some(Box::new(vec![ diff --git a/datafusion/src/physical_plan/expressions/correlation.rs b/datafusion/src/physical_plan/expressions/correlation.rs index 9e973b193974..0ce1c79c22ef 100644 --- a/datafusion/src/physical_plan/expressions/correlation.rs +++ b/datafusion/src/physical_plan/expressions/correlation.rs @@ -284,10 +284,10 @@ mod tests { #[test] fn correlation_f64_6() -> Result<()> { - let a = Arc::new(Float64Array::from_slice(vec![ + let a = Arc::new(Float64Array::from_slice(&[ 1_f64, 2_f64, 3_f64, 1.1_f64, 2.2_f64, 3.3_f64, ])); - let b = Arc::new(Float64Array::from_slice(vec![ + let b = Arc::new(Float64Array::from_slice(&[ 4_f64, 5_f64, 6_f64, 4.4_f64, 5.5_f64, 6.6_f64, ])); diff --git a/datafusion/src/physical_plan/expressions/covariance.rs b/datafusion/src/physical_plan/expressions/covariance.rs index d89d5736129b..c7fd95e6ee4f 100644 --- a/datafusion/src/physical_plan/expressions/covariance.rs +++ b/datafusion/src/physical_plan/expressions/covariance.rs @@ -468,10 +468,10 @@ mod tests { #[test] fn covariance_f64_6() -> Result<()> { - let a = Arc::new(Float64Array::from_slice(vec![ + let a = Arc::new(Float64Array::from_slice(&[ 1_f64, 2_f64, 3_f64, 1.1_f64, 2.2_f64, 3.3_f64, ])); - let b = Arc::new(Float64Array::from_slice(vec![ + let b = Arc::new(Float64Array::from_slice(&[ 4_f64, 5_f64, 6_f64, 4.4_f64, 5.5_f64, 6.6_f64, ])); diff --git a/datafusion/src/physical_plan/expressions/distinct_expressions.rs b/datafusion/src/physical_plan/expressions/distinct_expressions.rs index f0a741bb2f0b..dba5ea87e78b 100644 --- a/datafusion/src/physical_plan/expressions/distinct_expressions.rs +++ b/datafusion/src/physical_plan/expressions/distinct_expressions.rs @@ -878,7 +878,7 @@ mod tests { #[test] fn distinct_array_agg_i32() -> Result<()> { - let col: ArrayRef = Arc::new(Int32Array::from_slice(vec![1, 2, 7, 4, 5, 2])); + let col: ArrayRef = Arc::new(Int32Array::from_slice(&[1, 2, 7, 4, 5, 2])); let out = ScalarValue::List( Some(Box::new(vec![ diff --git a/datafusion/src/physical_plan/expressions/stddev.rs b/datafusion/src/physical_plan/expressions/stddev.rs index 72106f4cdded..d9f209a3bd74 100644 --- a/datafusion/src/physical_plan/expressions/stddev.rs +++ b/datafusion/src/physical_plan/expressions/stddev.rs @@ -260,7 +260,7 @@ mod tests { #[test] fn stddev_f64_1() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1_f64, 2_f64])); + let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1_f64, 2_f64])); generic_test_op!( a, DataType::Float64, @@ -272,7 +272,7 @@ mod tests { #[test] fn stddev_f64_2() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1.1_f64, 2_f64, 3_f64])); + let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1.1_f64, 2_f64, 3_f64])); generic_test_op!( a, DataType::Float64, @@ -284,7 +284,7 @@ mod tests { #[test] fn stddev_f64_3() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![ + let a: ArrayRef = Arc::new(Float64Array::from_slice(&[ 1_f64, 2_f64, 3_f64, 4_f64, 5_f64, ])); generic_test_op!( @@ -298,7 +298,7 @@ mod tests { #[test] fn stddev_f64_4() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1.1_f64, 2_f64, 3_f64])); + let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1.1_f64, 2_f64, 3_f64])); generic_test_op!( a, DataType::Float64, @@ -310,7 +310,7 @@ mod tests { #[test] fn stddev_i32() -> Result<()> { - let a: ArrayRef = Arc::new(Int32Array::from_slice(vec![1, 2, 3, 4, 5])); + let a: ArrayRef = Arc::new(Int32Array::from_slice(&[1, 2, 3, 4, 5])); generic_test_op!( a, DataType::Int32, @@ -322,7 +322,7 @@ mod tests { #[test] fn stddev_u32() -> Result<()> { - let a: ArrayRef = Arc::new(UInt32Array::from_slice(vec![ + let a: ArrayRef = Arc::new(UInt32Array::from_slice(&[ 1_u32, 2_u32, 3_u32, 4_u32, 5_u32, ])); generic_test_op!( @@ -336,7 +336,7 @@ mod tests { #[test] fn stddev_f32() -> Result<()> { - let a: ArrayRef = Arc::new(Float32Array::from_slice(vec![ + let a: ArrayRef = Arc::new(Float32Array::from_slice(&[ 1_f32, 2_f32, 3_f32, 4_f32, 5_f32, ])); generic_test_op!( @@ -361,7 +361,7 @@ mod tests { #[test] fn test_stddev_1_input() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1_f64])); + let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1_f64])); let schema = Schema::new(vec![Field::new("a", DataType::Float64, false)]); let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![a])?; diff --git a/datafusion/src/physical_plan/expressions/variance.rs b/datafusion/src/physical_plan/expressions/variance.rs index 0ab9aa3482b4..9d851611df00 100644 --- a/datafusion/src/physical_plan/expressions/variance.rs +++ b/datafusion/src/physical_plan/expressions/variance.rs @@ -345,7 +345,7 @@ mod tests { #[test] fn variance_f64_1() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1_f64, 2_f64])); + let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1_f64, 2_f64])); generic_test_op!( a, DataType::Float64, @@ -357,7 +357,7 @@ mod tests { #[test] fn variance_f64_2() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![ + let a: ArrayRef = Arc::new(Float64Array::from_slice(&[ 1_f64, 2_f64, 3_f64, 4_f64, 5_f64, ])); generic_test_op!( @@ -371,7 +371,7 @@ mod tests { #[test] fn variance_f64_3() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![ + let a: ArrayRef = Arc::new(Float64Array::from_slice(&[ 1_f64, 2_f64, 3_f64, 4_f64, 5_f64, ])); generic_test_op!( @@ -385,7 +385,7 @@ mod tests { #[test] fn variance_f64_4() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1.1_f64, 2_f64, 3_f64])); + let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1.1_f64, 2_f64, 3_f64])); generic_test_op!( a, DataType::Float64, @@ -397,7 +397,7 @@ mod tests { #[test] fn variance_i32() -> Result<()> { - let a: ArrayRef = Arc::new(Int32Array::from_slice(vec![1, 2, 3, 4, 5])); + let a: ArrayRef = Arc::new(Int32Array::from_slice(&[1, 2, 3, 4, 5])); generic_test_op!( a, DataType::Int32, @@ -409,7 +409,7 @@ mod tests { #[test] fn variance_u32() -> Result<()> { - let a: ArrayRef = Arc::new(UInt32Array::from_slice(vec![ + let a: ArrayRef = Arc::new(UInt32Array::from_slice(&[ 1_u32, 2_u32, 3_u32, 4_u32, 5_u32, ])); generic_test_op!( @@ -424,7 +424,7 @@ mod tests { #[test] fn variance_f32() -> Result<()> { let a: ArrayRef = - Float32Vec::from_slice(vec![1_f32, 2_f32, 3_f32, 4_f32, 5_f32]).as_arc(); + Float32Vec::from_slice(&[1_f32, 2_f32, 3_f32, 4_f32, 5_f32]).as_arc(); generic_test_op!( a, DataType::Float32, @@ -447,7 +447,7 @@ mod tests { #[test] fn test_variance_1_input() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1_f64])); + let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1_f64])); let schema = Schema::new(vec![Field::new("a", DataType::Float64, false)]); let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![a])?; diff --git a/datafusion/src/physical_plan/regex_expressions.rs b/datafusion/src/physical_plan/regex_expressions.rs index 71c0901a677e..470010d5491e 100644 --- a/datafusion/src/physical_plan/regex_expressions.rs +++ b/datafusion/src/physical_plan/regex_expressions.rs @@ -302,7 +302,7 @@ mod tests { ]); let patterns = Utf8Array::::from_slice(&vec![r"x.*-(\d*)-.*"; 4]); - let flags = Utf8Array::::from_slice(vec!["i"; 4]); + let flags = Utf8Array::::from_slice(&["i"; 4]); let result = regexp_matches(&array, &patterns, Some(&flags))?; @@ -317,9 +317,9 @@ mod tests { #[test] fn test_case_sensitive_regexp_match() { - let values = StringArray::from_slice(vec!["abc"; 5]); + let values = StringArray::from_slice(&["abc"; 5]); let patterns = - StringArray::from_slice(vec!["^(a)", "^(A)", "(b|d)", "(B|D)", "^(b|c)"]); + StringArray::from_slice(&["^(a)", "^(A)", "(b|d)", "(B|D)", "^(b|c)"]); let expected = vec![ Some(vec![Some("a")]), None, @@ -337,10 +337,10 @@ mod tests { #[test] fn test_case_insensitive_regexp_match() { - let values = StringArray::from_slice(vec!["abc"; 5]); + let values = StringArray::from_slice(&["abc"; 5]); let patterns = - StringArray::from_slice(vec!["^(a)", "^(A)", "(b|d)", "(B|D)", "^(b|c)"]); - let flags = StringArray::from_slice(vec!["i"; 5]); + StringArray::from_slice(&["^(a)", "^(A)", "(b|d)", "(B|D)", "^(b|c)"]); + let flags = StringArray::from_slice(&["i"; 5]); let expected = vec![ Some(vec![Some("a")]), diff --git a/datafusion/src/physical_plan/repartition.rs b/datafusion/src/physical_plan/repartition.rs index 2fde2d8caafa..9345b5b553a6 100644 --- a/datafusion/src/physical_plan/repartition.rs +++ b/datafusion/src/physical_plan/repartition.rs @@ -967,7 +967,7 @@ mod tests { let runtime = Arc::new(RuntimeEnv::default()); let batch = RecordBatch::try_from_iter(vec![( "a", - Arc::new(StringArray::from_slice(vec!["foo"])) as ArrayRef, + Arc::new(StringArray::from_slice(&["foo"])) as ArrayRef, )]) .unwrap(); let partitioning = Partitioning::Hash( diff --git a/datafusion/src/scalar.rs b/datafusion/src/scalar.rs index 0c0afc2f5b3e..847a9ddd65fd 100644 --- a/datafusion/src/scalar.rs +++ b/datafusion/src/scalar.rs @@ -2631,7 +2631,7 @@ mod tests { // Convert to length-2 array let array = scalar.to_array_of_size(2); let expected_vals = vec![ - (field_a.clone(), Int32Vec::from_slice(vec![23, 23]).as_arc()), + (field_a.clone(), Int32Vec::from_slice(&[23, 23]).as_arc()), ( field_b.clone(), Arc::new(BooleanArray::from_slice(&vec![false, false])) as ArrayRef, @@ -2645,8 +2645,8 @@ mod tests { Arc::new(StructArray::from_data( DataType::Struct(vec![field_e.clone(), field_f.clone()]), vec![ - Int16Vec::from_slice(vec![2, 2]).as_arc(), - Int64Vec::from_slice(vec![3, 3]).as_arc(), + Int16Vec::from_slice(&[2, 2]).as_arc(), + Int64Vec::from_slice(&[3, 3]).as_arc(), ], None, )) as ArrayRef, @@ -2722,7 +2722,7 @@ mod tests { let array: ArrayRef = ScalarValue::iter_to_array(scalars).unwrap(); let expected = Arc::new(struct_array_from(vec![ - (field_a, Int32Vec::from_slice(vec![23, 7, -1000]).as_arc()), + (field_a, Int32Vec::from_slice(&[23, 7, -1000]).as_arc()), ( field_b, Arc::new(BooleanArray::from_slice(&vec![false, true, true])) as ArrayRef, @@ -2737,8 +2737,8 @@ mod tests { Arc::new(StructArray::from_data( DataType::Struct(vec![field_e, field_f]), vec![ - Int16Vec::from_slice(vec![2, 4, 6]).as_arc(), - Int64Vec::from_slice(vec![3, 5, 7]).as_arc(), + Int16Vec::from_slice(&[2, 4, 6]).as_arc(), + Int64Vec::from_slice(&[3, 5, 7]).as_arc(), ], None, )) as ArrayRef, diff --git a/datafusion/tests/dataframe_functions.rs b/datafusion/tests/dataframe_functions.rs index 2b33e034ba0d..9a502742ad89 100644 --- a/datafusion/tests/dataframe_functions.rs +++ b/datafusion/tests/dataframe_functions.rs @@ -44,13 +44,13 @@ fn create_test_table() -> Result> { let batch = RecordBatch::try_new( schema.clone(), vec![ - Arc::new(Utf8Array::::from_slice(vec![ + Arc::new(Utf8Array::::from_slice(&[ "abcDEF", "abc123", "CBAdef", "123AbcDef", ])), - Arc::new(Int32Array::from_slice(vec![1, 10, 10, 100])), + Arc::new(Int32Array::from_slice(&[1, 10, 10, 100])), ], )?;