File tree Expand file tree Collapse file tree 6 files changed +46
-42
lines changed Expand file tree Collapse file tree 6 files changed +46
-42
lines changed Original file line number Diff line number Diff line change @@ -1106,9 +1106,8 @@ impl ScanInput {
11061106        rows
11071107    } 
11081108
1109-     /// Returns table predicate of all exprs. 
1110- pub ( crate )  fn  predicate ( & self )  -> Option < & Predicate >  { 
1111-         self . predicate . predicate ( ) 
1109+     pub ( crate )  fn  predicate_group ( & self )  -> & PredicateGroup  { 
1110+         & self . predicate 
11121111    } 
11131112
11141113    /// Returns number of memtables to scan. 
Original file line number Diff line number Diff line change @@ -632,8 +632,12 @@ impl RegionScanner for SeqScan {
632632        Ok ( ( ) ) 
633633    } 
634634
635-     fn  has_predicate ( & self )  -> bool  { 
636-         let  predicate = self . stream_ctx . input . predicate ( ) ; 
635+     fn  has_predicate_without_region ( & self )  -> bool  { 
636+         let  predicate = self 
637+             . stream_ctx 
638+             . input 
639+             . predicate_group ( ) 
640+             . predicate_without_region ( ) ; 
637641        predicate. map ( |p| !p. exprs ( ) . is_empty ( ) ) . unwrap_or ( false ) 
638642    } 
639643
Original file line number Diff line number Diff line change @@ -314,8 +314,12 @@ impl RegionScanner for SeriesScan {
314314        Ok ( ( ) ) 
315315    } 
316316
317-     fn  has_predicate ( & self )  -> bool  { 
318-         let  predicate = self . stream_ctx . input . predicate ( ) ; 
317+     fn  has_predicate_without_region ( & self )  -> bool  { 
318+         let  predicate = self 
319+             . stream_ctx 
320+             . input 
321+             . predicate_group ( ) 
322+             . predicate_without_region ( ) ; 
319323        predicate. map ( |p| !p. exprs ( ) . is_empty ( ) ) . unwrap_or ( false ) 
320324    } 
321325
Original file line number Diff line number Diff line change @@ -427,19 +427,15 @@ impl RegionScanner for UnorderedScan {
427427            . map_err ( BoxedError :: new) 
428428    } 
429429
430-     fn  has_predicate ( & self )  -> bool  { 
431-         let  predicate = self . stream_ctx . input . predicate ( ) ; 
432-         predicate
433-             . map ( |p| { 
434-                 if  self . metadata ( ) . partition_expr . is_some ( )  { 
435-                     // If there's partition expression, there must be at least one more expression to be a real predicate. As partition expr is always included in predicate. 
436-                     // TODO(discord9): better way to check for partition expr? 
437-                     p. exprs ( ) . len ( )  > 1 
438-                 }  else  { 
439-                     !p. exprs ( ) . is_empty ( ) 
440-                 } 
441-             } ) 
442-             . unwrap_or ( false ) 
430+     /// If this scanner have predicate other than region partition exprs 
431+ fn  has_predicate_without_region ( & self )  -> bool  { 
432+         let  predicate = self 
433+             . stream_ctx 
434+             . input 
435+             . predicate_group ( ) 
436+             . predicate_without_region ( ) ; 
437+ 
438+         predicate. map ( |p| !p. exprs ( ) . is_empty ( ) ) . unwrap_or ( false ) 
443439    } 
444440
445441    fn  set_logical_region ( & mut  self ,  logical_region :  bool )  { 
Original file line number Diff line number Diff line change @@ -444,8 +444,8 @@ pub trait RegionScanner: Debug + DisplayAs + Send {
444444        partition :  usize , 
445445    )  -> Result < SendableRecordBatchStream ,  BoxedError > ; 
446446
447-     /// Check if there is any predicate that may be executed in this scanner. 
448- fn  has_predicate ( & self )  -> bool ; 
447+     /// Check if there is any predicate exclude region partition exprs  that may be executed in this scanner. 
448+ fn  has_predicate_without_region ( & self )  -> bool ; 
449449
450450    /// Sets whether the scanner is reading a logical region. 
451451fn  set_logical_region ( & mut  self ,  logical_region :  bool ) ; 
@@ -857,7 +857,7 @@ impl RegionScanner for SinglePartitionScanner {
857857        Ok ( result. unwrap ( ) ) 
858858    } 
859859
860-     fn  has_predicate ( & self )  -> bool  { 
860+     fn  has_predicate_without_region ( & self )  -> bool  { 
861861        false 
862862    } 
863863
Original file line number Diff line number Diff line change @@ -335,25 +335,26 @@ impl ExecutionPlan for RegionScanExec {
335335            return  Ok ( Statistics :: new_unknown ( self . schema ( ) . as_ref ( ) ) ) ; 
336336        } 
337337
338-         let  statistics = if  self . append_mode  && !self . scanner . lock ( ) . unwrap ( ) . has_predicate ( )  { 
339-             let  column_statistics = self 
340-                 . arrow_schema 
341-                 . fields 
342-                 . iter ( ) 
343-                 . map ( |_| ColumnStatistics  { 
344-                     distinct_count :  Precision :: Exact ( self . total_rows ) , 
345-                     null_count :  Precision :: Exact ( 0 ) ,  // all null rows are counted for append-only table 
346-                     ..Default :: default ( ) 
347-                 } ) 
348-                 . collect ( ) ; 
349-             Statistics  { 
350-                 num_rows :  Precision :: Exact ( self . total_rows ) , 
351-                 total_byte_size :  Default :: default ( ) , 
352-                 column_statistics, 
353-             } 
354-         }  else  { 
355-             Statistics :: new_unknown ( & self . arrow_schema ) 
356-         } ; 
338+         let  statistics =
339+             if  self . append_mode  && !self . scanner . lock ( ) . unwrap ( ) . has_predicate_without_region ( )  { 
340+                 let  column_statistics = self 
341+                     . arrow_schema 
342+                     . fields 
343+                     . iter ( ) 
344+                     . map ( |_| ColumnStatistics  { 
345+                         distinct_count :  Precision :: Exact ( self . total_rows ) , 
346+                         null_count :  Precision :: Exact ( 0 ) ,  // all null rows are counted for append-only table 
347+                         ..Default :: default ( ) 
348+                     } ) 
349+                     . collect ( ) ; 
350+                 Statistics  { 
351+                     num_rows :  Precision :: Exact ( self . total_rows ) , 
352+                     total_byte_size :  Default :: default ( ) , 
353+                     column_statistics, 
354+                 } 
355+             }  else  { 
356+                 Statistics :: new_unknown ( & self . arrow_schema ) 
357+             } ; 
357358        Ok ( statistics) 
358359    } 
359360
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments