Mark1626 commented on code in PR #18999:
URL: https://github.com/apache/datafusion/pull/18999#discussion_r2621733783
##########
datafusion/functions/src/utils.rs:
##########
@@ -376,4 +425,70 @@ pub mod test {
}
}
}
+
+ #[test]
+ fn test_decimal32_to_i32() {
+ let cases = [
+ (123, 7, 0, Some(123)),
+ (1230, 7, 1, Some(123)),
+ (123000, 7, 3, Some(123)),
+ (1234567, 7, 2, Some(12345)),
+ (-1234567, 7, 2, Some(-12345)),
+ (1, 7, 0, Some(1)),
+ (123, 7, -3, None),
+ (123, 7, i8::MAX, None),
+ (999999999, 9, 0, Some(999999999)),
+ (999999999, 9, 3, Some(999999)),
+ ];
+
+ for (value, precision, scale, expected) in cases {
+ match decimal32_to_i32(value, precision, scale) {
+ Ok(actual) => {
+ assert_eq!(
+ actual,
+ expected.expect("Got value but expected none"),
+ "{value} and {precision} {scale} vs {expected:?}"
+ );
+ }
+ Err(_) => assert!(expected.is_none()),
Review Comment:
ok, I'll add an assertion on the expected error
--
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]