Ted-Jiang commented on code in PR #2694:
URL: https://github.com/apache/arrow-datafusion/pull/2694#discussion_r889657737


##########
datafusion/core/src/physical_plan/limit.rs:
##########
@@ -176,17 +184,18 @@ impl ExecutionPlan for GlobalLimitExec {
 
     fn statistics(&self) -> Statistics {
         let input_stats = self.input.statistics();
+        let skip = self.skip.unwrap_or(0);
         match input_stats {
             // if the input does not reach the limit globally, return input 
stats
             Statistics {
                 num_rows: Some(nr), ..
-            } if nr <= self.limit => input_stats,
+            } if nr - skip <= self.fetch.unwrap_or(usize::MAX) => input_stats,

Review Comment:
   nit: like
   ```
   if the input is greater than the limit, the num_row will be the limit
   ```
   and 
   ```
   // if the input is greater than the limit, the num_row will be greater
   // than the limit because the partitions will be limited separatly
   // the statistic
   ```
   limit should change to fetch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to