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

   ## Which issue does this PR close?
   
   - Part of #8227
   
   ## Rationale for this change
   
   Follow-up to #23936 (suggested 
[here](https://github.com/apache/datafusion/pull/23936#discussion_r3672861490)).
   
   #23936 made `FilterExec` report `num_rows: Exact(0)` for a provably empty 
result. Two places in the same operator still turn the same proof into an 
estimate:
   
   - `cap_at_rows` demotes `null_count` and `distinct_count` unconditionally
   - `total_byte_size` is computed after the "infeasibility branch", so a 
contradictory predicate (`a = 1 AND a = 2`) gives `Exact(0)` for `num_rows` and 
per-column `byte_size` but an inexact `total_byte_size`
   
   ## What changes are included in this PR?
   
   - `cap_at_rows` now maps an `Exact(0)` row bound to `Exact(0)`
   - `statistics_helper` reports `total_byte_size: Exact(0)` for a 
contradictory predicate instead of routing it through the selectivity estimate
   
   ## Are these changes tested?
   
   Yes, both by extending 
`test_filter_statistics_preserves_exactly_empty_input` with two assertions.
   
   Both assertions were confirmed to fail without the respective fix. No 
sqllogictest baselines change.
   
   ## Are there any user-facing changes?
   
   No breaking changes and no signature changes. `FilterExec` reports exact 
rather than inexact zeros for these statistics, visible in `EXPLAIN` output 
that shows statistics.
   
   ----
   
   Disclaimer: I used AI to assist in the code generation, I have manually 
reviewed the output and it matches my intention and understanding.
   


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