@@ -48,6 +48,7 @@ use sysinfo::System;
4848use self :: error:: ExecuteError ;
4949use self :: stream_schema_provider:: GlobalSchemaProvider ;
5050pub use self :: stream_schema_provider:: PartialTimeFilter ;
51+ use crate :: catalog:: column:: { Int64Type , TypedStatistics } ;
5152use crate :: catalog:: manifest:: Manifest ;
5253use crate :: catalog:: snapshot:: Snapshot ;
5354use crate :: catalog:: Snapshot as CatalogSnapshot ;
@@ -292,23 +293,26 @@ impl DateBinRequest {
292293 // extract start and end time to compare
293294 let date_bin_timestamp = bin. start . timestamp_millis ( ) ;
294295
296+ // Sum up the number of rows that fall within the bin
295297 let total_num_rows: u64 = all_manifest_files
296298 . iter ( )
297299 . flat_map ( |m| & m. files )
298- . filter ( |f| {
299- f. columns . iter ( ) . any ( |c| {
300+ . filter_map ( |f| {
301+ if f. columns . iter ( ) . any ( |c| {
300302 c. name == time_partition
301- && match & c. stats {
302- Some ( crate :: catalog:: column:: TypedStatistics :: Int ( int64_type) ) => {
303- let min =
304- DateTime :: from_timestamp_millis ( int64_type. min ) . unwrap ( ) ;
305- bin. start <= min && bin. end >= min
303+ && c. stats . as_ref ( ) . is_some_and ( |stats| match stats {
304+ TypedStatistics :: Int ( Int64Type { min, .. } ) => {
305+ let min = DateTime :: from_timestamp_millis ( * min) . unwrap ( ) ;
306+ bin. start <= min && bin. end >= min // Determines if a column matches the bin's time range.
306307 }
307308 _ => false ,
308- }
309- } )
309+ } )
310+ } ) {
311+ Some ( f. num_rows )
312+ } else {
313+ None
314+ }
310315 } )
311- . map ( |f| f. num_rows )
312316 . sum ( ) ;
313317
314318 date_bin_records. push ( DateBinRecord {
0 commit comments