Potential optimization for CASE WHEN for protecting against divide by zero #11570
Labels
enhancement
New feature or request
good first issue
Good for newcomers
optimizer
Optimizer rules
performance
Make DataFusion faster
Is your feature request related to a problem or challenge?
A common usage of
CASE WHEN
(particularly in the TPC-DS benchmark) is to protect against divide by zero errors. For example:The
CaseExpr
implementation is quite expensive and we could replace this whole expression with a divide kernel that returns null if the right hand side is zero (Rust has adiv_checked
function that already provides this functionality).arrow-rs already has the following code in
arrow-array/src/arithmetic.rs
, which is really close to what we need. I think we just need a version that returns anOption::None
instead of anErr
.Describe the solution you'd like
No response
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: