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

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   - N/A
   
   ## Rationale for this change
   
   `FilterExec::statistics()` uses interval arithmetic to narrow row-count 
estimates. The entry gate for this analysis is `check_support`, which decides 
whether an expression can participate. Previously, ScalarFunctionExpr was not 
recognized by `check_support`, so any filter containing a scalar UDF call (e.g. 
`ceil(x) > 12`) would skip interval analysis entirely and fall back to a flat 
50% selectivity guess, even if the UDF implemented `evaluate_bounds` and 
`propagate_constraints`.
   
   ## What changes are included in this PR?
   
   - `datafusion/physical-expr/src/intervals/utils.rs`: extend `check_support` 
to recognize `ScalarFunctionExpr`, gating on whether the return type and all 
argument expressions are supported.
   
   - `datafusion/functions/src/math/ceil.rs`: implement `evaluate_bounds` and 
`propagate_constraints` for `CeilFunc` as a working example of a UDF that 
benefits from the fix.
   
   ## Are these changes tested?
   
   Yes:
   
   - 5 unit tests in `intervals/utils.rs` covering supported/unsupported return 
types, unsupported child expressions, and `ScalarFunctionExpr` inside a 
`BinaryExpr`.
   
   - 1 integration test in `filter.rs` 
(`test_filter_statistics_ceil_scalar_fn`) that verifies 
`FilterExec::partition_statistics` produces a narrowed row estimate for 
`ceil(x) > 12.0` over a column with known min/max bounds.
   
   ## Are there any user-facing changes?
   
   No API changes. The improvement is visible as more accurate row estimates in 
query plans containing scalar UDF filters.
   


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