alamb commented on code in PR #10899:
URL: https://github.com/apache/datafusion/pull/10899#discussion_r1638227038
##########
datafusion/functions/src/math/round.rs:
##########
@@ -109,6 +109,9 @@ pub fn round(args: &[ArrayRef]) -> Result<ArrayRef> {
if args.len() == 2 {
decimal_places = ColumnarValue::Array(args[1].clone());
+ // if cast fails, we return error instead of panic. Better solution
would to update
+ // function signature and instead error during planning -- to be
improved later
+ _ = decimal_places.cast_to(&Int32, None)?;
Review Comment:
I think you could potentially just check the result of the conversion below
too
So instead of the following on line 120:
```rust
let decimal_places = decimal_places.try_into().unwrap();
```
something like this?
```rust
let decimal_places: i32 = decimal_places.try_into()
.map_err(|e| exec_datafusion_err!("Invalid value for
decimal places: {decimal_places}: {e}"))?;
```
--
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]