martin-g commented on code in PR #18776:
URL: https://github.com/apache/datafusion/pull/18776#discussion_r2535566542


##########
datafusion/core/src/physical_planner.rs:
##########
@@ -1578,6 +1583,20 @@ impl DefaultPhysicalPlanner {
     }
 }
 
+fn has_sufficient_rows_for_repartition(
+    input: &Arc<dyn ExecutionPlan>,
+    session_state: &SessionState,
+) -> Result<bool> {
+    let stats = input.partition_statistics(None)?;
+
+    if let Precision::Exact(num_rows) = stats.num_rows {

Review Comment:
   How about:
   
   ```suggestion
       if let Some(num_rows) = stats.num_rows.get_value() {
   ```
   This will cover both Exact and Inexact.



##########
datafusion/core/src/physical_planner.rs:
##########
@@ -1578,6 +1583,20 @@ impl DefaultPhysicalPlanner {
     }
 }
 
+fn has_sufficient_rows_for_repartition(
+    input: &Arc<dyn ExecutionPlan>,
+    session_state: &SessionState,
+) -> Result<bool> {
+    let stats = input.partition_statistics(None)?;
+
+    if let Precision::Exact(num_rows) = stats.num_rows {
+        let batch_size = session_state.config().batch_size();
+        return Ok(num_rows > batch_size);

Review Comment:
   ```suggestion
           return Ok(num_rows >= batch_size);
   ```



##########
datafusion/core/src/physical_planner.rs:
##########
@@ -1578,6 +1583,20 @@ impl DefaultPhysicalPlanner {
     }
 }
 
+fn has_sufficient_rows_for_repartition(
+    input: &Arc<dyn ExecutionPlan>,
+    session_state: &SessionState,
+) -> Result<bool> {
+    let stats = input.partition_statistics(None)?;

Review Comment:
   Does it have to fail the aggregation if the statistics fail for any reason ?
   IMO it would be better to return `Ok(true)` instead.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to