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

   ## Which issue does this PR close?
   
   - Part of #8227.
   
   ## Rationale for this change
   
   `Precision::with_estimated_selectivity` always demoted to inexact, so 
`Exact(0)` became `Inexact(0)`. Scaling zero by any selectivity is still 
exactly zero: filtering a provably empty input cannot produce rows.
   
   Because operators widen exact to inexact, emptiness could not propagate up a 
plan through statistics at all, it was lost at the first `FilterExec`. That 
operator already preserved the exact zero for a contradictory predicate and for 
column byte sizes, so the same fact came out exact or inexact depending on the 
path taken.
   
   This is the same reasoning as #23670, which stops 
`FileScanConfig::statistics()` demoting an exact zero when a filter is present, 
applied one level up. The two are independent, but together they let a proof of 
emptiness survive from the scan through the filter.
   
   ## What changes are included in this PR?
   
   - `with_estimated_selectivity` returns an exact zero unchanged. `Inexact(0)` 
is untouched: an estimate of zero is not a proof of zero.
   - `scale_byte_size` in `filter.rs` is removed, subsumed by the above.
   
   The method has four call sites, all in `FilterExec`.
   
   ## Are these changes tested?
   
   Yes. A unit test for the method, and a `FilterExec` test that a satisfiable 
predicate over an exactly empty input keeps `num_rows`, `total_byte_size` and 
column `byte_size` exact.
   
   `test_filter_statistics_empty_input_equality_ndv_zero` asserted `Inexact(0)` 
and now asserts `Exact(0)`; that is the intended behaviour change. No 
sqllogictest baselines change.
   
   ## Are there any user-facing changes?
   
   No breaking changes. `Precision::with_estimated_selectivity` is public and 
keeps its signature, but its documented contract changes: it previously stated 
it would always return inexact statistics, and it now preserves an exact zero. 
Callers relying on the old wording will see `Exact(0)` where they saw 
`Inexact(0)`.
   
   `FilterExec` over a provably empty input therefore reports exact 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