tustvold commented on code in PR #3021:
URL: https://github.com/apache/arrow-rs/pull/3021#discussion_r1014555110
##########
arrow-cast/src/cast.rs:
##########
@@ -6110,4 +6158,24 @@ mod tests {
);
assert!(casted_array.is_err());
}
+
+ #[test]
+ fn test_cast_floating_point_to_decimal128_overflow() {
+ let array = Float64Array::from(vec![100e10]);
+ let array = Arc::new(array) as ArrayRef;
+ let casted_array = cast_with_options(
+ &array,
+ &DataType::Decimal128(38, 30),
+ &CastOptions { safe: true },
+ );
+ assert!(casted_array.is_ok());
+ assert!(casted_array.unwrap().is_null(0));
+
+ let casted_array = cast_with_options(
+ &array,
+ &DataType::Decimal128(38, 30),
+ &CastOptions { safe: false },
+ );
+ assert!(casted_array.is_err());
Review Comment:
Typically we do something like
```
let err = operation.unwrap_err().to_string();
assert!(err.contains("EXPECTED), "{}", err)
```
To avoid false positives
--
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]