@@ -200,15 +200,12 @@ impl ExecutionPlan for FilterExec {
200
200
// assume filter selects 20% of rows if we cannot do anything smarter
201
201
// tracking issue for making this configurable:
202
202
// https://github.com/apache/arrow-datafusion/issues/8133
203
- let selectivity = 0.2_f32 ;
204
- let mut stats = input_stats. into_inexact ( ) ;
205
- if let Precision :: Inexact ( n) = stats. num_rows {
206
- stats. num_rows = Precision :: Inexact ( ( selectivity * n as f32 ) as usize ) ;
207
- }
208
- if let Precision :: Inexact ( n) = stats. total_byte_size {
209
- stats. total_byte_size =
210
- Precision :: Inexact ( ( selectivity * n as f32 ) as usize ) ;
211
- }
203
+ let selectivity = 0.2_f64 ;
204
+ let mut stats = input_stats. clone ( ) . into_inexact ( ) ;
205
+ stats. num_rows = stats. num_rows . with_estimated_selectivity ( selectivity) ;
206
+ stats. total_byte_size = stats
207
+ . total_byte_size
208
+ . with_estimated_selectivity ( selectivity) ;
212
209
return Ok ( stats) ;
213
210
}
214
211
@@ -222,14 +219,8 @@ impl ExecutionPlan for FilterExec {
222
219
223
220
// Estimate (inexact) selectivity of predicate
224
221
let selectivity = analysis_ctx. selectivity . unwrap_or ( 1.0 ) ;
225
- let num_rows = match num_rows. get_value ( ) {
226
- Some ( nr) => Precision :: Inexact ( ( * nr as f64 * selectivity) . ceil ( ) as usize ) ,
227
- None => Precision :: Absent ,
228
- } ;
229
- let total_byte_size = match total_byte_size. get_value ( ) {
230
- Some ( tbs) => Precision :: Inexact ( ( * tbs as f64 * selectivity) . ceil ( ) as usize ) ,
231
- None => Precision :: Absent ,
232
- } ;
222
+ let num_rows = num_rows. with_estimated_selectivity ( selectivity) ;
223
+ let total_byte_size = total_byte_size. with_estimated_selectivity ( selectivity) ;
233
224
234
225
let column_statistics = collect_new_statistics (
235
226
& input_stats. column_statistics ,
0 commit comments