@@ -1032,4 +1032,37 @@ mod tests {
10321032        assert ! ( filter. with_default_selectivity( 120 ) . is_err( ) ) ; 
10331033        Ok ( ( ) ) 
10341034    } 
1035+ 
1036+     #[ tokio:: test]  
1037+     async  fn  test_custom_filter_selectivity ( )  -> Result < ( ) >  { 
1038+         // Need a decimal to trigger inexact selectivity 
1039+         let  schema = Schema :: new ( vec ! [ Field :: new( "a" ,  DataType :: Decimal128 ( 2 ,  3 ) ,  false ) ] ) ; 
1040+         let  input = Arc :: new ( StatisticsExec :: new ( 
1041+             Statistics  { 
1042+                 num_rows :  Precision :: Inexact ( 1000 ) , 
1043+                 total_byte_size :  Precision :: Inexact ( 4000 ) , 
1044+                 column_statistics :  vec ! [ 
1045+                     ColumnStatistics  { 
1046+                         ..Default :: default ( ) 
1047+                     } , 
1048+                 ] , 
1049+             } , 
1050+             schema, 
1051+         ) ) ; 
1052+         // WHERE a = 10 
1053+         let  predicate = Arc :: new ( BinaryExpr :: new ( 
1054+             Arc :: new ( Column :: new ( "a" ,  0 ) ) , 
1055+             Operator :: Eq , 
1056+             Arc :: new ( Literal :: new ( ScalarValue :: Decimal128 ( Some ( 10 ) ,  10 , 10 ) ) ) , 
1057+         ) ) ; 
1058+         let  filter = FilterExec :: try_new ( predicate,  input) ?; 
1059+         let  statistics = filter. statistics ( ) ?; 
1060+         assert_eq ! ( statistics. num_rows,  Precision :: Inexact ( 200 ) ) ; 
1061+         assert_eq ! ( statistics. total_byte_size,  Precision :: Inexact ( 800 ) ) ; 
1062+         let  filter = filter. with_default_selectivity ( 40 ) ?; 
1063+         let  statistics = filter. statistics ( ) ?; 
1064+         assert_eq ! ( statistics. num_rows,  Precision :: Inexact ( 400 ) ) ; 
1065+         assert_eq ! ( statistics. total_byte_size,  Precision :: Inexact ( 1600 ) ) ; 
1066+         Ok ( ( ) ) 
1067+     } 
10351068} 
0 commit comments