-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersoptimizerOptimizer rulesOptimizer rulesperformanceMake DataFusion fasterMake DataFusion faster
Description
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:
CASE WHEN y > 0 THEN x / y ELSE null ENDThe 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 a div_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 an Option::None instead of an Err.
#[inline]
fn div_checked(self, rhs: Self) -> Result<Self, ArrowError> {
if rhs.is_zero() {
Err(ArrowError::DivideByZero)
} else {
self.checked_div(rhs).ok_or_else(|| {
ArrowError::ComputeError(format!(
"Overflow happened on: {:?} / {:?}",
self, rhs
))
})
}
}Describe the solution you'd like
No response
Describe alternatives you've considered
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersoptimizerOptimizer rulesOptimizer rulesperformanceMake DataFusion fasterMake DataFusion faster