File tree 1 file changed +14
-2
lines changed
datafusion/physical-plan/src
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -194,11 +194,23 @@ impl ExecutionPlan for FilterExec {
194
194
fn statistics ( & self ) -> Result < Statistics > {
195
195
let predicate = self . predicate ( ) ;
196
196
197
+ let input_stats = self . input . statistics ( ) ?;
197
198
let schema = self . schema ( ) ;
198
199
if !check_support ( predicate, & schema) {
199
- return Ok ( Statistics :: new_unknown ( & schema) ) ;
200
+ // assume filter selects 20% of rows if we cannot do anything smarter
201
+ // tracking issue for making this configurable:
202
+ // https://github.com/apache/arrow-datafusion/issues/8133
203
+ let selectivity = 0.2_f32 ;
204
+ let mut stats = input_stats. clone ( ) . 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
+ }
212
+ return Ok ( stats) ;
200
213
}
201
- let input_stats = self . input . statistics ( ) ?;
202
214
203
215
let num_rows = input_stats. num_rows ;
204
216
let total_byte_size = input_stats. total_byte_size ;
You can’t perform that action at this time.
0 commit comments