From 40541b4f2ea211b3a0339db06aaf8705e953f712 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 12 Jan 2024 14:10:37 +0100 Subject: [PATCH] cargo fmt --- tests/it/array/growable/map.rs | 5 +- tests/it/array/growable/struct_.rs | 5 +- tests/it/array/growable/union.rs | 6 +- tests/it/compute/aggregate/memory.rs | 6 +- tests/it/compute/arithmetics/time.rs | 115 ++++++++++++++++----------- tests/it/io/csv/read.rs | 5 +- tests/it/io/print.rs | 11 ++- tests/it/scalar/fixed_size_list.rs | 10 ++- tests/it/scalar/list.rs | 12 ++- 9 files changed, 117 insertions(+), 58 deletions(-) diff --git a/tests/it/array/growable/map.rs b/tests/it/array/growable/map.rs index 4025e6b52b..c1c367dcbc 100644 --- a/tests/it/array/growable/map.rs +++ b/tests/it/array/growable/map.rs @@ -29,7 +29,10 @@ fn some_values() -> (DataType, Vec>) { Field::new("key", DataType::Utf8, true), Field::new("val", DataType::Int32, true), ]; - (DataType::Struct(std::sync::Arc::new(fields)), vec![strings, ints]) + ( + DataType::Struct(std::sync::Arc::new(fields)), + vec![strings, ints], + ) } #[test] diff --git a/tests/it/array/growable/struct_.rs b/tests/it/array/growable/struct_.rs index 9ab9ba7303..16d600dfe2 100644 --- a/tests/it/array/growable/struct_.rs +++ b/tests/it/array/growable/struct_.rs @@ -24,7 +24,10 @@ fn some_values() -> (DataType, Vec>) { Field::new("f1", DataType::Utf8, true), Field::new("f2", DataType::Int32, true), ]; - (DataType::Struct(std::sync::Arc::new(fields)), vec![strings, ints]) + ( + DataType::Struct(std::sync::Arc::new(fields)), + vec![strings, ints], + ) } #[test] diff --git a/tests/it/array/growable/union.rs b/tests/it/array/growable/union.rs index 756d4458f1..65185ffecf 100644 --- a/tests/it/array/growable/union.rs +++ b/tests/it/array/growable/union.rs @@ -74,8 +74,10 @@ fn dense() -> Result<()> { #[test] fn complex_dense() -> Result<()> { - let fixed_size_type = - DataType::FixedSizeList(std::sync::Arc::new(Field::new("i", DataType::UInt16, true)), 3); + let fixed_size_type = DataType::FixedSizeList( + std::sync::Arc::new(Field::new("i", DataType::UInt16, true)), + 3, + ); let fields = vec![ Field::new("a", DataType::Int32, true), diff --git a/tests/it/compute/aggregate/memory.rs b/tests/it/compute/aggregate/memory.rs index cfee4e7e38..1c5133aa03 100644 --- a/tests/it/compute/aggregate/memory.rs +++ b/tests/it/compute/aggregate/memory.rs @@ -24,8 +24,10 @@ fn utf8() { #[test] fn fixed_size_list() { - let data_type = - DataType::FixedSizeList(std::sync::Arc::new(Field::new("elem", DataType::Float32, false)), 3); + let data_type = DataType::FixedSizeList( + std::sync::Arc::new(Field::new("elem", DataType::Float32, false)), + 3, + ); let values = Box::new(Float32Array::from_slice([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])); let a = FixedSizeListArray::new(data_type, values, None); assert_eq!(6 * std::mem::size_of::(), estimated_bytes_size(&a)); diff --git a/tests/it/compute/arithmetics/time.rs b/tests/it/compute/arithmetics/time.rs index 6fdeec358c..2c4d8a4a02 100644 --- a/tests/it/compute/arithmetics/time.rs +++ b/tests/it/compute/arithmetics/time.rs @@ -6,42 +6,47 @@ use arrow2::types::months_days_ns; #[test] fn test_adding_timestamp() { - let timestamp = - PrimitiveArray::from([Some(100000i64), Some(200000i64), None, Some(300000i64)]).to( - DataType::Timestamp(TimeUnit::Second, Some(std::sync::Arc::new("America/New_york".to_string()))), - ); + let timestamp = PrimitiveArray::from([Some(100000i64), Some(200000i64), None, Some(300000i64)]) + .to(DataType::Timestamp( + TimeUnit::Second, + Some(std::sync::Arc::new("America/New_york".to_string())), + )); let duration = PrimitiveArray::from([Some(10i64), Some(20i64), None, Some(30i64)]) .to(DataType::Duration(TimeUnit::Second)); let result = add_duration(×tamp, &duration); - let expected = - PrimitiveArray::from([Some(100010i64), Some(200020i64), None, Some(300030i64)]).to( - DataType::Timestamp(TimeUnit::Second, Some(std::sync::Arc::new("America/New_york".to_string()))), - ); + let expected = PrimitiveArray::from([Some(100010i64), Some(200020i64), None, Some(300030i64)]) + .to(DataType::Timestamp( + TimeUnit::Second, + Some(std::sync::Arc::new("America/New_york".to_string())), + )); assert_eq!(result, expected); let duration = PrimitiveScalar::from(Some(10i64)).to(DataType::Duration(TimeUnit::Second)); let result = add_duration_scalar(×tamp, &duration); - let expected = - PrimitiveArray::from([Some(100010i64), Some(200010i64), None, Some(300010i64)]).to( - DataType::Timestamp(TimeUnit::Second, Some(std::sync::Arc::new("America/New_york".to_string()))), - ); + let expected = PrimitiveArray::from([Some(100010i64), Some(200010i64), None, Some(300010i64)]) + .to(DataType::Timestamp( + TimeUnit::Second, + Some(std::sync::Arc::new("America/New_york".to_string())), + )); assert_eq!(result, expected); } #[test] fn test_adding_duration_different_scale() { - let timestamp = - PrimitiveArray::from([Some(100000i64), Some(200000i64), None, Some(300000i64)]).to( - DataType::Timestamp(TimeUnit::Second, Some(std::sync::Arc::new("America/New_york".to_string()))), - ); - let expected = - PrimitiveArray::from([Some(100010i64), Some(200020i64), None, Some(300030i64)]).to( - DataType::Timestamp(TimeUnit::Second, Some(std::sync::Arc::new("America/New_york".to_string()))), - ); + let timestamp = PrimitiveArray::from([Some(100000i64), Some(200000i64), None, Some(300000i64)]) + .to(DataType::Timestamp( + TimeUnit::Second, + Some(std::sync::Arc::new("America/New_york".to_string())), + )); + let expected = PrimitiveArray::from([Some(100010i64), Some(200020i64), None, Some(300030i64)]) + .to(DataType::Timestamp( + TimeUnit::Second, + Some(std::sync::Arc::new("America/New_york".to_string())), + )); // Testing duration in milliseconds let duration = PrimitiveArray::from([Some(10_000i64), Some(20_000i64), None, Some(30_000i64)]) @@ -69,20 +74,29 @@ fn test_adding_duration_different_scale() { #[test] fn test_adding_subtract_timestamps_scale() { let timestamp = PrimitiveArray::from([Some(10i64), Some(20i64), None, Some(30i64)]).to( - DataType::Timestamp(TimeUnit::Millisecond, Some(std::sync::Arc::new("America/New_york".to_string()))), + DataType::Timestamp( + TimeUnit::Millisecond, + Some(std::sync::Arc::new("America/New_york".to_string())), + ), ); let duration = PrimitiveArray::from([Some(1i64), Some(2i64), None, Some(3i64)]) .to(DataType::Duration(TimeUnit::Second)); let expected = PrimitiveArray::from([Some(1_010i64), Some(2_020i64), None, Some(3_030i64)]).to( - DataType::Timestamp(TimeUnit::Millisecond, Some(std::sync::Arc::new("America/New_york".to_string()))), + DataType::Timestamp( + TimeUnit::Millisecond, + Some(std::sync::Arc::new("America/New_york".to_string())), + ), ); let result = add_duration(×tamp, &duration); assert_eq!(result, expected); let timestamp = PrimitiveArray::from([Some(10i64), Some(20i64), None, Some(30i64)]).to( - DataType::Timestamp(TimeUnit::Nanosecond, Some(std::sync::Arc::new("America/New_york".to_string()))), + DataType::Timestamp( + TimeUnit::Nanosecond, + Some(std::sync::Arc::new("America/New_york".to_string())), + ), ); let duration = PrimitiveArray::from([Some(1i64), Some(2i64), None, Some(3i64)]) .to(DataType::Duration(TimeUnit::Second)); @@ -104,33 +118,37 @@ fn test_adding_subtract_timestamps_scale() { #[test] fn test_subtract_timestamp() { - let timestamp = - PrimitiveArray::from([Some(100000i64), Some(200000i64), None, Some(300000i64)]).to( - DataType::Timestamp(TimeUnit::Second, Some(std::sync::Arc::new("America/New_york".to_string()))), - ); + let timestamp = PrimitiveArray::from([Some(100000i64), Some(200000i64), None, Some(300000i64)]) + .to(DataType::Timestamp( + TimeUnit::Second, + Some(std::sync::Arc::new("America/New_york".to_string())), + )); let duration = PrimitiveArray::from([Some(10i64), Some(20i64), None, Some(30i64)]) .to(DataType::Duration(TimeUnit::Second)); let result = subtract_duration(×tamp, &duration); - let expected = - PrimitiveArray::from([Some(99990i64), Some(199980i64), None, Some(299970i64)]).to( - DataType::Timestamp(TimeUnit::Second, Some(std::sync::Arc::new("America/New_york".to_string()))), - ); + let expected = PrimitiveArray::from([Some(99990i64), Some(199980i64), None, Some(299970i64)]) + .to(DataType::Timestamp( + TimeUnit::Second, + Some(std::sync::Arc::new("America/New_york".to_string())), + )); assert_eq!(result, expected); } #[test] fn test_subtracting_duration_different_scale() { - let timestamp = - PrimitiveArray::from([Some(100000i64), Some(200000i64), None, Some(300000i64)]).to( - DataType::Timestamp(TimeUnit::Second, Some(std::sync::Arc::new("America/New_york".to_string()))), - ); - let expected = - PrimitiveArray::from([Some(99990i64), Some(199980i64), None, Some(299970i64)]).to( - DataType::Timestamp(TimeUnit::Second, Some(std::sync::Arc::new("America/New_york".to_string()))), - ); + let timestamp = PrimitiveArray::from([Some(100000i64), Some(200000i64), None, Some(300000i64)]) + .to(DataType::Timestamp( + TimeUnit::Second, + Some(std::sync::Arc::new("America/New_york".to_string())), + )); + let expected = PrimitiveArray::from([Some(99990i64), Some(199980i64), None, Some(299970i64)]) + .to(DataType::Timestamp( + TimeUnit::Second, + Some(std::sync::Arc::new("America/New_york".to_string())), + )); // Testing duration in milliseconds let duration = PrimitiveArray::from([Some(10_000i64), Some(20_000i64), None, Some(30_000i64)]) @@ -158,21 +176,28 @@ fn test_subtracting_duration_different_scale() { #[test] fn test_subtracting_subtract_timestamps_scale() { let timestamp = PrimitiveArray::from([Some(10i64), Some(20i64), None, Some(30i64)]).to( - DataType::Timestamp(TimeUnit::Millisecond, Some(std::sync::Arc::new("America/New_york".to_string()))), + DataType::Timestamp( + TimeUnit::Millisecond, + Some(std::sync::Arc::new("America/New_york".to_string())), + ), ); let duration = PrimitiveArray::from([Some(1i64), Some(2i64), None, Some(3i64)]) .to(DataType::Duration(TimeUnit::Second)); - let expected = - PrimitiveArray::from([Some(-990i64), Some(-1_980i64), None, Some(-2_970i64)]).to( - DataType::Timestamp(TimeUnit::Millisecond, Some(std::sync::Arc::new("America/New_york".to_string()))), - ); + let expected = PrimitiveArray::from([Some(-990i64), Some(-1_980i64), None, Some(-2_970i64)]) + .to(DataType::Timestamp( + TimeUnit::Millisecond, + Some(std::sync::Arc::new("America/New_york".to_string())), + )); let result = subtract_duration(×tamp, &duration); assert_eq!(result, expected); let timestamp = PrimitiveArray::from([Some(10i64), Some(20i64), None, Some(30i64)]).to( - DataType::Timestamp(TimeUnit::Nanosecond, Some(std::sync::Arc::new("America/New_york".to_string()))), + DataType::Timestamp( + TimeUnit::Nanosecond, + Some(std::sync::Arc::new("America/New_york".to_string())), + ), ); let duration = PrimitiveArray::from([Some(1i64), Some(2i64), None, Some(3i64)]) .to(DataType::Duration(TimeUnit::Second)); diff --git a/tests/it/io/csv/read.rs b/tests/it/io/csv/read.rs index ee9f584d46..083b180591 100644 --- a/tests/it/io/csv/read.rs +++ b/tests/it/io/csv/read.rs @@ -426,7 +426,10 @@ fn deserialize_timestamp() -> Result<()> { let input = vec!["1996-12-19T16:34:57-02:00", "1996-12-19T16:34:58-02:00"]; let input = input.join("\n"); - let data_type = DataType::Timestamp(TimeUnit::Millisecond, Some(std::sync::Arc::new("-01:00".to_string()))); + let data_type = DataType::Timestamp( + TimeUnit::Millisecond, + Some(std::sync::Arc::new("-01:00".to_string())), + ); let expected = Int64Array::from([Some(851020497000), Some(851020498000)]).to(data_type.clone()); diff --git a/tests/it/io/print.rs b/tests/it/io/print.rs index 3f23ea4c1a..9ff261f9da 100644 --- a/tests/it/io/print.rs +++ b/tests/it/io/print.rs @@ -161,7 +161,10 @@ fn write_timestamp_second_with_tz() { ]; check_datetime!( i64, - DataType::Timestamp(TimeUnit::Second, Some(std::sync::Arc::new("UTC".to_string()))), + DataType::Timestamp( + TimeUnit::Second, + Some(std::sync::Arc::new("UTC".to_string())) + ), 11111111, expected ); @@ -327,7 +330,11 @@ fn write_struct() -> Result<()> { let validity = Some(Bitmap::from(&[true, false, true])); - let array = StructArray::new(DataType::Struct(std::sync::Arc::new(fields)), values, validity); + let array = StructArray::new( + DataType::Struct(std::sync::Arc::new(fields)), + values, + validity, + ); let columns = Chunk::new(vec![&array as &dyn Array]); diff --git a/tests/it/scalar/fixed_size_list.rs b/tests/it/scalar/fixed_size_list.rs index ef8eddffb9..65f646466e 100644 --- a/tests/it/scalar/fixed_size_list.rs +++ b/tests/it/scalar/fixed_size_list.rs @@ -7,7 +7,10 @@ use arrow2::{ #[allow(clippy::eq_op)] #[test] fn equal() { - let dt = DataType::FixedSizeList(std::sync::Arc::new(Field::new("a", DataType::Boolean, true)), 2); + let dt = DataType::FixedSizeList( + std::sync::Arc::new(Field::new("a", DataType::Boolean, true)), + 2, + ); let a = FixedSizeListScalar::new( dt.clone(), Some(BooleanArray::from_slice([true, false]).boxed()), @@ -26,7 +29,10 @@ fn equal() { #[test] fn basics() { - let dt = DataType::FixedSizeList(std::sync::Arc::new(Field::new("a", DataType::Boolean, true)), 2); + let dt = DataType::FixedSizeList( + std::sync::Arc::new(Field::new("a", DataType::Boolean, true)), + 2, + ); let a = FixedSizeListScalar::new( dt.clone(), Some(BooleanArray::from_slice([true, false]).boxed()), diff --git a/tests/it/scalar/list.rs b/tests/it/scalar/list.rs index 44e6e32b26..ad2eed126d 100644 --- a/tests/it/scalar/list.rs +++ b/tests/it/scalar/list.rs @@ -7,7 +7,11 @@ use arrow2::{ #[allow(clippy::eq_op)] #[test] fn equal() { - let dt = DataType::List(std::sync::Arc::new(Field::new("a", DataType::Boolean, true))); + let dt = DataType::List(std::sync::Arc::new(Field::new( + "a", + DataType::Boolean, + true, + ))); let a = ListScalar::::new( dt.clone(), Some(BooleanArray::from_slice([true, false]).boxed()), @@ -23,7 +27,11 @@ fn equal() { #[test] fn basics() { - let dt = DataType::List(std::sync::Arc::new(Field::new("a", DataType::Boolean, true))); + let dt = DataType::List(std::sync::Arc::new(Field::new( + "a", + DataType::Boolean, + true, + ))); let a = ListScalar::::new( dt.clone(), Some(BooleanArray::from_slice([true, false]).boxed()),