irenjj commented on code in PR #12049:
URL: https://github.com/apache/datafusion/pull/12049#discussion_r1720984271
##########
datafusion/physical-expr/src/expressions/case.rs:
##########
@@ -386,6 +420,47 @@ impl CaseExpr {
Ok(ColumnarValue::Array(zip(&when_value, &then_value, &else_)?))
}
+
+ fn divide_by_zero_expr(&self, batch: &RecordBatch) ->
Result<ColumnarValue> {
+ let return_type = self.data_type(&batch.schema())?;
+
+ // start with nulls as default output
+ let mut current_value = new_null_array(&return_type, batch.num_rows());
+ let mut remainder = BooleanArray::from(vec![true; batch.num_rows()]);
+ let when_value = BooleanArray::from(vec![true; batch.num_rows()]);
+ for i in 0..self.when_then_expr.len() {
+ let then_value = self.when_then_expr[i]
+ .1
+ .evaluate(batch)?;
Review Comment:
hi @andygrove , Maybe we can optimize div_zero by simplifying the check on
`when_expr` and directly running the evaluation of `then_expr`. However, in the
`evaluate()`, it seems that arrow's `div()` is called directly, and `div()`
will throw an error when division by zero occurs. So, what we need to do is
either modify or add a new div function to handle division by zero, right?
--
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]