Repository: jorgecarleitao/arrow2
Pull request #1217 (2022-08-09 05:06:57)

Removed `Count` (parquet statistics)
This level of indirection is not required (since we already have `Array` for dynamic typing). It makes it easier to handle statistics.

codecov[bot]: # [Codecov](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1217?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) Report
> Merging [#1217](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1217?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) (12617c9) into [main](https://codecov.io/gh/jorgecarleitao/arrow2/commit/838decac839f66d1f54f9c0cc418e5e0c8b37f87?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) (838deca) will **decrease** coverage by `0.00%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##             main    #1217      +/-   ##
==========================================
- Coverage   83.17%   83.17%   -0.01%     
==========================================
  Files         358      358              
  Lines       37255    37244      -11     
==========================================
- Hits        30986    30976      -10     
+ Misses       6269     6268       -1     
```


| [Impacted Files](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1217?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) | Coverage Δ | |
|---|---|---|
| [src/io/parquet/read/statistics/mod.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1217/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2lvL3BhcnF1ZXQvcmVhZC9zdGF0aXN0aWNzL21vZC5ycw==) | `87.83% <100.00%> (-0.32%)` | :arrow_down: |
| [src/bitmap/utils/slice\_iterator.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1217/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2JpdG1hcC91dGlscy9zbGljZV9pdGVyYXRvci5ycw==) | `98.78% <0.00%> (+1.21%)` | :arrow_up: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao).


Patch:
diff --git a/src/io/parquet/read/statistics/mod.rs b/src/io/parquet/read/statistics/mod.rs
index 7c8f22fdcf..8b136360b1 100644
--- a/src/io/parquet/read/statistics/mod.rs
+++ b/src/io/parquet/read/statistics/mod.rs
@@ -32,28 +32,13 @@ use self::list::DynMutableListArray;
 
 use super::get_field_columns;
 
-/// Enum of a count statistics
-#[derive(Debug, PartialEq)]
-pub enum Count {
-    /// simple arrays have a count of UInt64
-    Single(UInt64Array),
-    /// list arrays have a count as a list of UInt64
-    List(ListArray<i32>),
-    /// list arrays have a count as a list of UInt64
-    LargeList(ListArray<i64>),
-    /// struct arrays have a count as a struct of UInt64
-    Struct(StructArray),
-    /// map arrays have a count as a map of UInt64
-    Map(MapArray),
-}
-
 /// Arrow-deserialized parquet Statistics of a file
 #[derive(Debug, PartialEq)]
 pub struct Statistics {
-    /// number of nulls.
-    pub null_count: Count,
-    /// number of dictinct values
-    pub distinct_count: Count,
+    /// number of nulls. This is a [`UInt64Array`] for non-nested types
+    pub null_count: Box<dyn Array>,
+    /// number of dictinct values. This is a [`UInt64Array`] for non-nested types
+    pub distinct_count: Box<dyn Array>,
     /// Minimum
     pub min_value: Box<dyn Array>,
     /// Maximum
@@ -76,98 +61,88 @@ struct MutableStatistics {
 impl From<MutableStatistics> for Statistics {
     fn from(mut s: MutableStatistics) -> Self {
         let null_count = if let PhysicalType::Struct = s.null_count.data_type().to_physical_type() {
-            let a = s
-                .null_count
+            s.null_count
                 .as_box()
                 .as_any()
                 .downcast_ref::<StructArray>()
                 .unwrap()
-                .clone();
-            Count::Struct(a)
+                .clone()
+                .boxed()
         } else if let PhysicalType::Map = s.null_count.data_type().to_physical_type() {
-            let a = s
-                .null_count
+            s.null_count
                 .as_box()
                 .as_any()
                 .downcast_ref::<MapArray>()
                 .unwrap()
-                .clone();
-            Count::Map(a)
+                .clone()
+                .boxed()
         } else if let PhysicalType::List = s.null_count.data_type().to_physical_type() {
-            let a = s
-                .null_count
+            s.null_count
                 .as_box()
                 .as_any()
                 .downcast_ref::<ListArray<i32>>()
                 .unwrap()
-                .clone();
-            Count::List(a)
+                .clone()
+                .boxed()
         } else if let PhysicalType::LargeList = s.null_count.data_type().to_physical_type() {
-            let a = s
-                .null_count
+            s.null_count
                 .as_box()
                 .as_any()
                 .downcast_ref::<ListArray<i64>>()
                 .unwrap()
-                .clone();
-            Count::LargeList(a)
+                .clone()
+                .boxed()
         } else {
-            let a = s
-                .null_count
+            s.null_count
                 .as_box()
                 .as_any()
                 .downcast_ref::<UInt64Array>()
                 .unwrap()
-                .clone();
-            Count::Single(a)
+                .clone()
+                .boxed()
         };
         let distinct_count = if let PhysicalType::Struct =
             s.distinct_count.data_type().to_physical_type()
         {
-            let a = s
-                .distinct_count
+            s.distinct_count
                 .as_box()
                 .as_any()
                 .downcast_ref::<StructArray>()
                 .unwrap()
-                .clone();
-            Count::Struct(a)
+                .clone()
+                .boxed()
         } else if let PhysicalType::Map = s.distinct_count.data_type().to_physical_type() {
-            let a = s
-                .distinct_count
+            s.distinct_count
                 .as_box()
                 .as_any()
                 .downcast_ref::<MapArray>()
                 .unwrap()
-                .clone();
-            Count::Map(a)
+                .clone()
+                .boxed()
         } else if let PhysicalType::List = s.distinct_count.data_type().to_physical_type() {
-            let a = s
-                .distinct_count
+            s.distinct_count
                 .as_box()
                 .as_any()
                 .downcast_ref::<ListArray<i32>>()
                 .unwrap()
-                .clone();
-            Count::List(a)
+                .clone()
+                .boxed()
         } else if let PhysicalType::LargeList = s.distinct_count.data_type().to_physical_type() {
-            let a = s
-                .distinct_count
+            s.distinct_count
                 .as_box()
                 .as_any()
                 .downcast_ref::<ListArray<i64>>()
                 .unwrap()
-                .clone();
-            Count::LargeList(a)
+                .clone()
+                .boxed()
         } else {
-            let a = s
-                .distinct_count
+            s.distinct_count
                 .as_box()
                 .as_any()
                 .downcast_ref::<UInt64Array>()
                 .unwrap()
-                .clone();
-            Count::Single(a)
+                .clone()
+                .boxed()
         };
         Self {
             null_count,


Test patch:
diff --git a/tests/it/io/parquet/mod.rs b/tests/it/io/parquet/mod.rs
index 55baceaa9a..04d838e96a 100644
--- a/tests/it/io/parquet/mod.rs
+++ b/tests/it/io/parquet/mod.rs
@@ -409,32 +409,32 @@ pub fn pyarrow_nullable(column: &str) -> Box<dyn Array> {
 pub fn pyarrow_nullable_statistics(column: &str) -> Statistics {
     match column {
         "int64" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(3)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(3)]).boxed(),
             min_value: Box::new(Int64Array::from_slice([-256])),
             max_value: Box::new(Int64Array::from_slice([9])),
         },
         "float64" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(3)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(3)]).boxed(),
             min_value: Box::new(Float64Array::from_slice([0.0])),
             max_value: Box::new(Float64Array::from_slice([9.0])),
         },
         "string" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(4)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(4)]).boxed(),
             min_value: Box::new(Utf8Array::<i32>::from_slice([""])),
             max_value: Box::new(Utf8Array::<i32>::from_slice(["def"])),
         },
         "bool" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(4)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(4)]).boxed(),
             min_value: Box::new(BooleanArray::from_slice([false])),
             max_value: Box::new(BooleanArray::from_slice([true])),
         },
         "timestamp_ms" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(3)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(3)]).boxed(),
             min_value: Box::new(
                 Int64Array::from_slice([0]).to(DataType::Timestamp(TimeUnit::Millisecond, None)),
             ),
@@ -443,8 +443,8 @@ pub fn pyarrow_nullable_statistics(column: &str) -> Statistics {
             ),
         },
         "uint32" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(3)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(3)]).boxed(),
             min_value: Box::new(UInt32Array::from_slice([0])),
             max_value: Box::new(UInt32Array::from_slice([9])),
         },
@@ -454,33 +454,33 @@ pub fn pyarrow_nullable_statistics(column: &str) -> Statistics {
             };
 
             Statistics {
-                distinct_count: Count::Single(UInt64Array::from([None])),
-                null_count: Count::Single(UInt64Array::from([Some(0)])),
+                distinct_count: UInt64Array::from([None]).boxed(),
+                null_count: UInt64Array::from([Some(0)]).boxed(),
                 min_value: new_dict(Box::new(Int32Array::from_slice([10]))),
                 max_value: new_dict(Box::new(Int32Array::from_slice([200]))),
             }
         }
         "decimal_9" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(3)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(3)]).boxed(),
             min_value: Box::new(Int128Array::from_slice([-256]).to(DataType::Decimal(9, 0))),
             max_value: Box::new(Int128Array::from_slice([9]).to(DataType::Decimal(9, 0))),
         },
         "decimal_18" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(3)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(3)]).boxed(),
             min_value: Box::new(Int128Array::from_slice([-256]).to(DataType::Decimal(18, 0))),
             max_value: Box::new(Int128Array::from_slice([9]).to(DataType::Decimal(18, 0))),
         },
         "decimal_26" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(3)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(3)]).boxed(),
             min_value: Box::new(Int128Array::from_slice([-256]).to(DataType::Decimal(26, 0))),
             max_value: Box::new(Int128Array::from_slice([9]).to(DataType::Decimal(26, 0))),
         },
         "timestamp_us" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(3)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(3)]).boxed(),
             min_value: Box::new(
                 Int64Array::from_slice([-256]).to(DataType::Timestamp(TimeUnit::Microsecond, None)),
             ),
@@ -489,8 +489,8 @@ pub fn pyarrow_nullable_statistics(column: &str) -> Statistics {
             ),
         },
         "timestamp_s" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(3)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(3)]).boxed(),
             min_value: Box::new(
                 Int64Array::from_slice([-256]).to(DataType::Timestamp(TimeUnit::Second, None)),
             ),
@@ -499,8 +499,8 @@ pub fn pyarrow_nullable_statistics(column: &str) -> Statistics {
             ),
         },
         "timestamp_s_utc" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single(UInt64Array::from([Some(3)])),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(3)]).boxed(),
             min_value: Box::new(Int64Array::from_slice([-256]).to(DataType::Timestamp(
                 TimeUnit::Second,
                 Some("UTC".to_string()),
@@ -564,7 +564,7 @@ pub fn pyarrow_required(column: &str) -> Box<dyn Array> {
 
 pub fn pyarrow_required_statistics(column: &str) -> Statistics {
     let mut s = pyarrow_nullable_statistics(column);
-    s.null_count = Count::Single(UInt64Array::from([Some(0)]));
+    s.null_count = UInt64Array::from([Some(0)]).boxed();
     s
 }
 
@@ -584,50 +584,50 @@ pub fn pyarrow_nested_nullable_statistics(column: &str) -> Statistics {
 
     match column {
         "list_int16" => Statistics {
-            distinct_count: Count::List(new_list(UInt64Array::from([None]).boxed(), true)),
-            null_count: Count::List(new_list(UInt64Array::from([Some(1)]).boxed(), true)),
+            distinct_count: new_list(UInt64Array::from([None]).boxed(), true).boxed(),
+            null_count: new_list(UInt64Array::from([Some(1)]).boxed(), true).boxed(),
             min_value: new_list(Box::new(Int16Array::from_slice([0])), true).boxed(),
             max_value: new_list(Box::new(Int16Array::from_slice([10])), true).boxed(),
         },
         "list_bool" => Statistics {
-            distinct_count: Count::List(new_list(UInt64Array::from([None]).boxed(), true)),
-            null_count: Count::List(new_list(UInt64Array::from([Some(1)]).boxed(), true)),
+            distinct_count: new_list(UInt64Array::from([None]).boxed(), true).boxed(),
+            null_count: new_list(UInt64Array::from([Some(1)]).boxed(), true).boxed(),
             min_value: new_list(Box::new(BooleanArray::from_slice([false])), true).boxed(),
             max_value: new_list(Box::new(BooleanArray::from_slice([true])), true).boxed(),
         },
         "list_utf8" => Statistics {
-            distinct_count: Count::List(new_list(UInt64Array::from([None]).boxed(), true)),
-            null_count: Count::List(new_list(UInt64Array::from([Some(1)]).boxed(), true)),
+            distinct_count: new_list(UInt64Array::from([None]).boxed(), true).boxed(),
+            null_count: new_list(UInt64Array::from([Some(1)]).boxed(), true).boxed(),
             min_value: new_list(Box::new(Utf8Array::<i32>::from_slice([""])), true).boxed(),
             max_value: new_list(Box::new(Utf8Array::<i32>::from_slice(["ccc"])), true).boxed(),
         },
         "list_large_binary" => Statistics {
-            distinct_count: Count::List(new_list(UInt64Array::from([None]).boxed(), true)),
-            null_count: Count::List(new_list(UInt64Array::from([Some(1)]).boxed(), true)),
+            distinct_count: new_list(UInt64Array::from([None]).boxed(), true).boxed(),
+            null_count: new_list(UInt64Array::from([Some(1)]).boxed(), true).boxed(),
             min_value: new_list(Box::new(BinaryArray::<i64>::from_slice([b""])), true).boxed(),
             max_value: new_list(Box::new(BinaryArray::<i64>::from_slice([b"ccc"])), true).boxed(),
         },
         "list_int64" => Statistics {
-            distinct_count: Count::List(new_list(UInt64Array::from([None]).boxed(), true)),
-            null_count: Count::List(new_list(UInt64Array::from([Some(1)]).boxed(), true)),
+            distinct_count: new_list(UInt64Array::from([None]).boxed(), true).boxed(),
+            null_count: new_list(UInt64Array::from([Some(1)]).boxed(), true).boxed(),
             min_value: new_list(Box::new(Int64Array::from_slice([0])), true).boxed(),
             max_value: new_list(Box::new(Int64Array::from_slice([10])), true).boxed(),
         },
         "list_int64_required" => Statistics {
-            distinct_count: Count::List(new_list(UInt64Array::from([None]).boxed(), true)),
-            null_count: Count::List(new_list(UInt64Array::from([Some(1)]).boxed(), true)),
+            distinct_count: new_list(UInt64Array::from([None]).boxed(), true).boxed(),
+            null_count: new_list(UInt64Array::from([Some(1)]).boxed(), true).boxed(),
             min_value: new_list(Box::new(Int64Array::from_slice([0])), false).boxed(),
             max_value: new_list(Box::new(Int64Array::from_slice([10])), false).boxed(),
         },
         "list_int64_required_required" | "list_int64_optional_required" => Statistics {
-            distinct_count: Count::List(new_list(UInt64Array::from([None]).boxed(), false)),
-            null_count: Count::List(new_list(UInt64Array::from([Some(0)]).boxed(), false)),
+            distinct_count: new_list(UInt64Array::from([None]).boxed(), false).boxed(),
+            null_count: new_list(UInt64Array::from([Some(0)]).boxed(), false).boxed(),
             min_value: new_list(Box::new(Int64Array::from_slice([0])), false).boxed(),
             max_value: new_list(Box::new(Int64Array::from_slice([10])), false).boxed(),
         },
         "list_nested_i64" => Statistics {
-            distinct_count: Count::List(new_list(UInt64Array::from([None]).boxed(), true)),
-            null_count: Count::List(new_list(UInt64Array::from([Some(2)]).boxed(), true)),
+            distinct_count: new_list(UInt64Array::from([None]).boxed(), true).boxed(),
+            null_count: new_list(UInt64Array::from([Some(2)]).boxed(), true).boxed(),
             min_value: new_list(
                 new_list(Box::new(Int64Array::from_slice([0])), true).boxed(),
                 true,
@@ -640,8 +640,8 @@ pub fn pyarrow_nested_nullable_statistics(column: &str) -> Statistics {
             .boxed(),
         },
         "list_nested_inner_required_required_i64" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single([Some(0)].into()),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(0)]).boxed(),
             min_value: new_list(
                 new_list(Box::new(Int64Array::from_slice([0])), true).boxed(),
                 true,
@@ -654,8 +654,8 @@ pub fn pyarrow_nested_nullable_statistics(column: &str) -> Statistics {
             .boxed(),
         },
         "list_nested_inner_required_i64" => Statistics {
-            distinct_count: Count::Single(UInt64Array::from([None])),
-            null_count: Count::Single([Some(0)].into()),
+            distinct_count: UInt64Array::from([None]).boxed(),
+            null_count: UInt64Array::from([Some(0)]).boxed(),
             min_value: new_list(
                 new_list(Box::new(Int64Array::from_slice([0])), true).boxed(),
                 true,
@@ -698,26 +698,28 @@ pub fn pyarrow_nested_edge_statistics(column: &str) -> Statistics {
 
     match column {
         "simple" => Statistics {
-            distinct_count: Count::List(new_list(UInt64Array::from([None]).boxed())),
-            null_count: Count::List(new_list(UInt64Array::from([Some(0)]).boxed())),
+            distinct_count: new_list(UInt64Array::from([None]).boxed()).boxed(),
+            null_count: new_list(UInt64Array::from([Some(0)]).boxed()).boxed(),
             min_value: new_list(Box::new(Int64Array::from([Some(0)]))).boxed(),
             max_value: new_list(Box::new(Int64Array::from([Some(1)]))).boxed(),
         },
         "null" => Statistics {
-            distinct_count: Count::List(new_list(UInt64Array::from([None]).boxed())),
-            null_count: Count::List(new_list(UInt64Array::from([Some(1)]).boxed())),
+            distinct_count: new_list(UInt64Array::from([None]).boxed()).boxed(),
+            null_count: new_list(UInt64Array::from([Some(1)]).boxed()).boxed(),
             min_value: new_list(Box::new(Int64Array::from([None]))).boxed(),
             max_value: new_list(Box::new(Int64Array::from([None]))).boxed(),
         },
         "struct_list_nullable" => Statistics {
-            distinct_count: Count::Struct(new_struct(
+            distinct_count: new_struct(
                 vec![new_list(Box::new(UInt64Array::from([None]))).boxed()],
                 names.clone(),
-            )),
-            null_count: Count::Struct(new_struct(
+            )
+            .boxed(),
+            null_count: new_struct(
                 vec![new_list(Box::new(UInt64Array::from([Some(1)]))).boxed()],
                 names.clone(),
-            )),
+            )
+            .boxed(),
             min_value: Box::new(new_struct(
                 vec![new_list(Box::new(Utf8Array::<i32>::from_slice(["a"]))).boxed()],
                 names.clone(),
@@ -812,20 +814,22 @@ pub fn pyarrow_struct_statistics(column: &str) -> Statistics {
 
     match column {
         "struct" | "struct_nullable" => Statistics {
-            distinct_count: Count::Struct(new_struct(
+            distinct_count: new_struct(
                 vec![
                     Box::new(UInt64Array::from([None])),
                     Box::new(UInt64Array::from([None])),
                 ],
                 names.clone(),
-            )),
-            null_count: Count::Struct(new_struct(
+            )
+            .boxed(),
+            null_count: new_struct(
                 vec![
                     Box::new(UInt64Array::from([Some(4)])),
                     Box::new(UInt64Array::from([Some(4)])),
                 ],
                 names.clone(),
-            )),
+            )
+            .boxed(),
             min_value: Box::new(new_struct(
                 vec![
                     Box::new(Utf8Array::<i32>::from_slice([""])),
@@ -842,7 +846,7 @@ pub fn pyarrow_struct_statistics(column: &str) -> Statistics {
             )),
         },
         "struct_struct" => Statistics {
-            distinct_count: Count::Struct(new_struct(
+            distinct_count: new_struct(
                 vec![
                     new_struct(
                         vec![
@@ -855,8 +859,9 @@ pub fn pyarrow_struct_statistics(column: &str) -> Statistics {
                     UInt64Array::from([None]).boxed(),
                 ],
                 names.clone(),
-            )),
-            null_count: Count::Struct(new_struct(
+            )
+            .boxed(),
+            null_count: new_struct(
                 vec![
                     new_struct(
                         vec![
@@ -869,7 +874,8 @@ pub fn pyarrow_struct_statistics(column: &str) -> Statistics {
                     UInt64Array::from([Some(4)]).boxed(),
                 ],
                 names.clone(),
-            )),
+            )
+            .boxed(),
             min_value: new_struct(
                 vec![
                     new_struct(
@@ -902,7 +908,7 @@ pub fn pyarrow_struct_statistics(column: &str) -> Statistics {
             .boxed(),
         },
         "struct_struct_nullable" => Statistics {
-            distinct_count: Count::Struct(new_struct(
+            distinct_count: new_struct(
                 vec![
                     new_struct(
                         vec![
@@ -915,8 +921,9 @@ pub fn pyarrow_struct_statistics(column: &str) -> Statistics {
                     UInt64Array::from([None]).boxed(),
                 ],
                 names.clone(),
-            )),
-            null_count: Count::Struct(new_struct(
+            )
+            .boxed(),
+            null_count: new_struct(
                 vec![
                     new_struct(
                         vec![
@@ -929,7 +936,8 @@ pub fn pyarrow_struct_statistics(column: &str) -> Statistics {
                     UInt64Array::from([Some(5)]).boxed(),
                 ],
                 names.clone(),
-            )),
+            )
+            .boxed(),
             min_value: new_struct(
                 vec![
                     new_struct(
@@ -1043,20 +1051,22 @@ pub fn pyarrow_map_statistics(column: &str) -> Statistics {
 
     match column {
         "map" => Statistics {
-            distinct_count: Count::Map(new_map(
+            distinct_count: new_map(
                 vec![
                     UInt64Array::from([None]).boxed(),
                     UInt64Array::from([None]).boxed(),
                 ],
                 names.clone(),
-            )),
-            null_count: Count::Map(new_map(
+            )
+            .boxed(),
+            null_count: new_map(
                 vec![
                     UInt64Array::from([Some(0)]).boxed(),
                     UInt64Array::from([Some(0)]).boxed(),
                 ],
                 names.clone(),
-            )),
+            )
+            .boxed(),
             min_value: Box::new(new_map(
                 vec![
                     Utf8Array::<i32>::from_slice(["a1"]).boxed(),
@@ -1073,20 +1083,22 @@ pub fn pyarrow_map_statistics(column: &str) -> Statistics {
             )),
         },
         "map_nullable" => Statistics {
-            distinct_count: Count::Map(new_map(
+            distinct_count: new_map(
                 vec![
                     UInt64Array::from([None]).boxed(),
                     UInt64Array::from([None]).boxed(),
                 ],
                 names.clone(),
-            )),
-            null_count: Count::Map(new_map(
+            )
+            .boxed(),
+            null_count: new_map(
                 vec![
                     UInt64Array::from([Some(0)]).boxed(),
                     UInt64Array::from([Some(1)]).boxed(),
                 ],
                 names.clone(),
-            )),
+            )
+            .boxed(),
             min_value: Box::new(new_map(
                 vec![
                     Utf8Array::<i32>::from_slice(["a1"]).boxed(),