himadripal commented on code in PR #6836:
URL: https://github.com/apache/arrow-rs/pull/6836#discussion_r1870487495
##########
arrow-cast/src/cast/decimal.rs:
##########
@@ -112,8 +112,19 @@ where
};
Ok(match cast_options.safe {
- true => array.unary_opt(f),
- false => array.try_unary(|x| f(x).ok_or_else(|| error(x)))?,
+ true => {
+ array.unary_opt(|x| {
+ f(x).filter(|v| O::is_valid_decimal_precision(*v,
output_precision))
+ })
+ }
+ false => {
+ array.try_unary(|x| {
+ f(x).ok_or_else(|| error(x))
+ .and_then(|v|{
+ O:: validate_decimal_precision(v,
output_precision).map(|_| v)
Review Comment:
I thought about it, but then there are other examples where is it done this
way, so kept it there. We can also do this as part of first error check point -
inside this method
```rust
let error = cast_decimal_to_decimal_error::<I, O>(output_precision,
output_scale);
```
--
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]