diff --git a/src/io/parquet/read/statistics/mod.rs b/src/io/parquet/read/statistics/mod.rs index d27123fc51e..7c8f22fdcf1 100644 --- a/src/io/parquet/read/statistics/mod.rs +++ b/src/io/parquet/read/statistics/mod.rs @@ -10,6 +10,7 @@ use parquet2::statistics::{ BinaryStatistics, BooleanStatistics, FixedLenStatistics, PrimitiveStatistics, Statistics as ParquetStatistics, }; +use parquet2::types::int96_to_i64_ns; use crate::array::*; use crate::datatypes::IntervalUnit; @@ -487,13 +488,41 @@ fn push( UInt64 => primitive::push(from, min, max, |x: i64| Ok(x as u64)), Timestamp(time_unit, _) => { let time_unit = *time_unit; - primitive::push(from, min, max, |x: i64| { - Ok(primitive::timestamp( - type_.logical_type.as_ref(), - time_unit, - x, - )) - }) + if physical_type == &ParquetPhysicalType::Int96 { + let from = from.map(|from| { + let from = from + .as_any() + .downcast_ref::>() + .unwrap(); + PrimitiveStatistics:: { + primitive_type: from.primitive_type.clone(), + null_count: from.null_count, + distinct_count: from.distinct_count, + min_value: from.min_value.map(int96_to_i64_ns), + max_value: from.max_value.map(int96_to_i64_ns), + } + }); + primitive::push( + from.as_ref().map(|x| x as &dyn ParquetStatistics), + min, + max, + |x: i64| { + Ok(primitive::timestamp( + type_.logical_type.as_ref(), + time_unit, + x, + )) + }, + ) + } else { + primitive::push(from, min, max, |x: i64| { + Ok(primitive::timestamp( + type_.logical_type.as_ref(), + time_unit, + x, + )) + }) + } } Float32 => primitive::push(from, min, max, |x: f32| Ok(x as f32)), Float64 => primitive::push(from, min, max, |x: f64| Ok(x as f64)),