@@ -151,9 +151,6 @@ pub struct FileScanConfig {
151
151
pub file_groups : Vec < FileGroup > ,
152
152
/// Table constraints
153
153
pub constraints : Constraints ,
154
- /// Estimated overall statistics of the files, taking `filters` into account.
155
- /// Defaults to [`Statistics::new_unknown`].
156
- pub statistics : Statistics ,
157
154
/// Columns on which to project the data. Indexes that are higher than the
158
155
/// number of columns of `file_schema` refer to `table_partition_cols`.
159
156
pub projection : Option < Vec < usize > > ,
@@ -412,7 +409,6 @@ impl FileScanConfigBuilder {
412
409
table_partition_cols,
413
410
constraints,
414
411
file_groups,
415
- statistics,
416
412
output_ordering,
417
413
file_compression_type,
418
414
new_lines_in_values,
@@ -426,9 +422,9 @@ impl From<FileScanConfig> for FileScanConfigBuilder {
426
422
Self {
427
423
object_store_url : config. object_store_url ,
428
424
file_schema : config. file_schema ,
429
- file_source : config. file_source ,
425
+ file_source : config. file_source . clone ( ) ,
430
426
file_groups : config. file_groups ,
431
- statistics : Some ( config. statistics ) ,
427
+ statistics : config. file_source . statistics ( ) . ok ( ) ,
432
428
output_ordering : config. output_ordering ,
433
429
file_compression_type : Some ( config. file_compression_type ) ,
434
430
new_lines_in_values : Some ( config. new_lines_in_values ) ,
@@ -610,7 +606,6 @@ impl FileScanConfig {
610
606
file_schema,
611
607
file_groups : vec ! [ ] ,
612
608
constraints : Constraints :: empty ( ) ,
613
- statistics,
614
609
projection : None ,
615
610
limit : None ,
616
611
table_partition_cols : vec ! [ ] ,
@@ -625,7 +620,8 @@ impl FileScanConfig {
625
620
/// Set the file source
626
621
#[ deprecated( since = "47.0.0" , note = "use FileScanConfigBuilder instead" ) ]
627
622
pub fn with_source ( mut self , file_source : Arc < dyn FileSource > ) -> Self {
628
- self . file_source = file_source. with_statistics ( self . statistics . clone ( ) ) ;
623
+ self . file_source =
624
+ file_source. with_statistics ( Statistics :: new_unknown ( & self . file_schema ) ) ;
629
625
self
630
626
}
631
627
@@ -639,7 +635,6 @@ impl FileScanConfig {
639
635
/// Set the statistics of the files
640
636
#[ deprecated( since = "47.0.0" , note = "use FileScanConfigBuilder instead" ) ]
641
637
pub fn with_statistics ( mut self , statistics : Statistics ) -> Self {
642
- self . statistics = statistics. clone ( ) ;
643
638
self . file_source = self . file_source . with_statistics ( statistics) ;
644
639
self
645
640
}
@@ -654,10 +649,7 @@ impl FileScanConfig {
654
649
}
655
650
656
651
fn projected_stats ( & self ) -> Statistics {
657
- let statistics = self
658
- . file_source
659
- . statistics ( )
660
- . unwrap_or ( self . statistics . clone ( ) ) ;
652
+ let statistics = self . file_source . statistics ( ) . unwrap ( ) ;
661
653
662
654
let table_cols_stats = self
663
655
. projection_indices ( )
@@ -804,7 +796,7 @@ impl FileScanConfig {
804
796
return (
805
797
Arc :: clone ( & self . file_schema ) ,
806
798
self . constraints . clone ( ) ,
807
- self . statistics . clone ( ) ,
799
+ self . file_source . statistics ( ) . unwrap ( ) . clone ( ) ,
808
800
self . output_ordering . clone ( ) ,
809
801
) ;
810
802
}
@@ -949,7 +941,11 @@ impl Debug for FileScanConfig {
949
941
write ! ( f, "FileScanConfig {{" ) ?;
950
942
write ! ( f, "object_store_url={:?}, " , self . object_store_url) ?;
951
943
952
- write ! ( f, "statistics={:?}, " , self . statistics) ?;
944
+ write ! (
945
+ f,
946
+ "statistics={:?}, " ,
947
+ self . file_source. statistics( ) . unwrap( )
948
+ ) ?;
953
949
954
950
DisplayAs :: fmt_as ( self , DisplayFormatType :: Verbose , f) ?;
955
951
write ! ( f, "}}" )
@@ -2161,13 +2157,13 @@ mod tests {
2161
2157
assert ! ( config. constraints. is_empty( ) ) ;
2162
2158
2163
2159
// Verify statistics are set to unknown
2164
- assert_eq ! ( config. statistics. num_rows, Precision :: Absent ) ;
2165
- assert_eq ! ( config. statistics. total_byte_size, Precision :: Absent ) ;
2160
+ assert_eq ! ( config. file_source . statistics( ) . unwrap ( ) . num_rows, Precision :: Absent ) ;
2161
+ assert_eq ! ( config. file_source . statistics( ) . unwrap ( ) . total_byte_size, Precision :: Absent ) ;
2166
2162
assert_eq ! (
2167
- config. statistics. column_statistics. len( ) ,
2163
+ config. file_source . statistics( ) . unwrap ( ) . column_statistics. len( ) ,
2168
2164
file_schema. fields( ) . len( )
2169
2165
) ;
2170
- for stat in config. statistics . column_statistics {
2166
+ for stat in config. file_source . statistics ( ) . unwrap ( ) . column_statistics {
2171
2167
assert_eq ! ( stat. distinct_count, Precision :: Absent ) ;
2172
2168
assert_eq ! ( stat. min_value, Precision :: Absent ) ;
2173
2169
assert_eq ! ( stat. max_value, Precision :: Absent ) ;
0 commit comments