This is an automated email from the ASF dual-hosted git repository.
jeffreyvo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 8b2b1efc75 Add another decimal cast edge test case (#7078)
8b2b1efc75 is described below
commit 8b2b1efc754144350ee9fe03b22e91585a05bd40
Author: Piotr Findeisen <[email protected]>
AuthorDate: Thu Feb 6 10:49:46 2025 +0100
Add another decimal cast edge test case (#7078)
* Add another decimal cast edge test case
Before 1019f5b27d3596077bcdd7e10b67e2c6d4cfbf02 this test would fail, as
the cast produced 1. 0 is an edge case worth explicitly testing for.
* typo/fmt
Co-authored-by: Felipe Oliveira Carvalho <[email protected]>
---------
Co-authored-by: Felipe Oliveira Carvalho <[email protected]>
---
arrow-cast/src/cast/mod.rs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arrow-cast/src/cast/mod.rs b/arrow-cast/src/cast/mod.rs
index 00d6b14964..c448ad9601 100644
--- a/arrow-cast/src/cast/mod.rs
+++ b/arrow-cast/src/cast/mod.rs
@@ -10000,6 +10000,16 @@ mod tests {
result.unwrap().as_primitive::<Decimal128Type>().value(0),
520
);
+
+ // Cast 0 of decimal(3, 0) type to decimal(2, 0)
+ assert_eq!(
+ &cast(
+ &create_decimal_array(vec![Some(0)], 3, 0).unwrap(),
+ &DataType::Decimal128(2, 0)
+ )
+ .unwrap(),
+ &(Arc::new(create_decimal_array(vec![Some(0)], 2, 0).unwrap()) as
ArrayRef)
+ );
}
#[test]