You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "vim89 (via GitHub)" <gi...@apache.org> on 2025/07/28 09:38:28 UTC

[PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

vim89 opened a new pull request, #16941:
URL: https://github.com/apache/datafusion/pull/16941

   ## Which issue does this PR close?
   
   - Partially closes #15873
   
   ## Rationale for this change
   
   `EmptyExec` previously returned **"unknown"** statistics for both global and partition-level queries, which impacts planner accuracy. This change provides exact-zero stats for EmptyExec, aligning with how other operators like `AggregateExec` and `PlaceholderRowExec` handle partition statistics.
   
   ## What changes are included in this PR?
   
   - Implemented `partition_statistics(...)` for `EmptyExec`:
     - Sets `num_rows` and `total_byte_size` to `Precision::Exact(0)`
     - Populates `column_statistics` with one `ColumnStatistics::new_unknown()` per schema field
   - Added unit test `empty_multi_partition_statistics`:
     - Verifies default 1-partition behavior: global and partition 0 return zero stats, invalid partition errors
     - Verifies 2-partition behavior: partitions 0 and 1 return zero stats, invalid partition errors
   - Added a `TreeRender` branch to `DisplayAs` to provide informative display of the operator:  
     `"EmptyExec: partitions=X, fields=Y"`
   - No other execution plans or tests were modified
   
   ## Are these changes tested?
   
   Yes.  
   - New test covers all relevant edge cases.  
   - The full test suite still passes without regressions.
   
   ## Are there any user-facing changes?
   
   No.  
   This change affects internal planner behavior only; no public APIs or outputs are changed.


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "vim89 (via GitHub)" <gi...@apache.org>.
vim89 commented on code in PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#discussion_r2245505745


##########
datafusion/physical-plan/src/empty.rs:
##########
@@ -229,4 +243,62 @@ mod tests {
         assert!(empty.execute(20, task_ctx).is_err());
         Ok(())
     }
+
+    #[test]

Review Comment:
   Ah well, thank you & apologies for oversight.
   Let me run integration tests and align column stats for values instead of Absent. 



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#issuecomment-3154663425

   I started the tests and marked the PR as a draft. Please mark it as ready for review when it is ready for another look


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#discussion_r2245170771


##########
datafusion/physical-plan/src/empty.rs:
##########
@@ -229,4 +243,62 @@ mod tests {
         assert!(empty.execute(20, task_ctx).is_err());
         Ok(())
     }
+
+    #[test]

Review Comment:
   You can find the partition statistics in the dedicated file: https://github.com/apache/datafusion/blob/main/datafusion/core/tests/physical_optimizer/partition_statistics.rs. 
   
   It also contains the real exection to check the results



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey closed pull request #16941: Implementing partition_statistics for EmptyExec (Issue #15873)
URL: https://github.com/apache/datafusion/pull/16941


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#issuecomment-3152112526

   @xudong963  does this one look good to you now?


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#discussion_r2240765144


##########
datafusion/physical-plan/src/empty.rs:
##########
@@ -165,23 +169,28 @@ impl ExecutionPlan for EmptyExec {
                 );
             }
         }
+        // Build explicit stats: exact zero rows and bytes, with unknown columns
+        let mut stats = Statistics::default()
+            .with_num_rows(Precision::Exact(0))
+            .with_total_byte_size(Precision::Exact(0));
+
+        // Add unknown column stats for each field in schema

Review Comment:
   Technically speaking we could probably also add known statistics values too



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#issuecomment-3673170519

   Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#issuecomment-3419142379

   Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "vim89 (via GitHub)" <gi...@apache.org>.
vim89 commented on PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#issuecomment-3153621141

   > @xudong963 does this one look good to you now?
   
   @alamb I'm working on using column stats for values instead of Absent. Then Let me run integration tests 


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "vim89 (via GitHub)" <gi...@apache.org>.
vim89 commented on PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#issuecomment-3135269236

   @alamb @xudong963 Added known statistics values. Please review


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "vim89 (via GitHub)" <gi...@apache.org>.
vim89 commented on code in PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#discussion_r2241514304


##########
datafusion/physical-plan/src/empty.rs:
##########
@@ -165,23 +169,28 @@ impl ExecutionPlan for EmptyExec {
                 );
             }
         }
+        // Build explicit stats: exact zero rows and bytes, with unknown columns
+        let mut stats = Statistics::default()
+            .with_num_rows(Precision::Exact(0))
+            .with_total_byte_size(Precision::Exact(0));
+
+        // Add unknown column stats for each field in schema

Review Comment:
   Yes thanks for highlighting. Let me quickly try 



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Implementing partition_statistics for EmptyExec (Issue #15873) [datafusion]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #16941:
URL: https://github.com/apache/datafusion/pull/16941#issuecomment-3698320769

   Feel free to reopen if it becomes active again


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org