tmi commented on code in PR #10899: URL: https://github.com/apache/datafusion/pull/10899#discussion_r1638502083
########## datafusion/functions/src/math/round.rs: ########## @@ -128,29 +134,41 @@ pub fn round(args: &[ArrayRef]) -> Result<ArrayRef> { } )) as ArrayRef) } - ColumnarValue::Array(decimal_places) => Ok(Arc::new(make_function_inputs2!( - &args[0], - decimal_places, - "value", - "decimal_places", - Float64Array, - Int64Array, - { - |value: f64, decimal_places: i64| { - (value * 10.0_f64.powi(decimal_places.try_into().unwrap())) - .round() - / 10.0_f64.powi(decimal_places.try_into().unwrap()) + ColumnarValue::Array(_) => { + let ColumnarValue::Array(decimal_places) = + decimal_places.cast_to(&Int32, None).map_err(|e| { + exec_datafusion_err!("Invalid values for decimal places: {e}") + })? + else { + panic!("Unexpected result of ColumnarValue::Array.cast") Review Comment: and the panic in the else part is there because we "forget" that the result of the `cast_to` is still an array, ie, it doesnt change into a scalar. But technically it's an unreachable part of the code -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org