yongster commented on code in PR #10707:
URL: https://github.com/apache/arrow-rs/pull/10707#discussion_r3794824934
##########
arrow-cast/src/cast/mod.rs:
##########
@@ -372,31 +385,38 @@ where
))
})?;
+ let overflow = |v: T::Native| {
+ ArrowError::CastError(format!(
+ "Cannot cast to {}({precision}, {scale}). Overflowing on {v:?}",
+ D::PREFIX,
+ ))
+ };
+
let array = if scale < 0 {
match cast_options.safe {
true => array.unary_opt::<_, D>(|v| {
- v.as_()
- .div_checked(scale_factor)
- .ok()
+ integer_to_decimal_native::<_, M>(v)
+ .and_then(|v| v.div_checked(scale_factor).ok())
Review Comment:
Good point, thank you. I will take a closer look at the `scale < 0` case and
adjust the conversion order so values are not rejected before scaling can
make
them fit the target decimal bounds.
--
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]