tmi commented on code in PR #10899:
URL: https://github.com/apache/datafusion/pull/10899#discussion_r1638499463
##########
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:
but I need to squeeze the `cast_to` in there, right? I didn't find a way how
to do that more elegantly
it's the same thing like the `let decimal_places: i32 =
decimal_places.try_into()` in the scalar case, except that we can't just
`try_into` since the type is dynamic in the arrow array
--
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]