advancedxy commented on code in PR #3243:
URL: https://github.com/apache/iceberg-rust/pull/3243#discussion_r4244321704
##########
crates/iceberg/src/transform/truncate.rs:
##########
@@ -831,12 +860,52 @@ mod test {
#[test]
fn test_decimal_literal() {
- let input = Datum::decimal(decimal_new(1065, 0)).unwrap();
- let res = super::Truncate::new(50)
- .transform_literal(&input)
- .unwrap()
- .unwrap();
- assert_eq!(res, Datum::decimal(decimal_new(1050, 0)).unwrap(),);
+ for (precision, scale, value, expected) in [
+ (9, 0, 1065, 1050),
+ (9, 2, 1065, 1050),
+ (9, 2, -1065, -1100),
+ (9, 2, 1050, 1050),
+ (9, 2, 0, 0),
+ (9, 5, 1065, 1050),
+ (38, 2, 1065, 1050),
+ ] {
+ let data_type = Decimal { precision, scale };
+ let input = Datum::new(data_type.clone(),
PrimitiveLiteral::Int128(value));
+ let res = super::Truncate::new(50)
+ .transform_literal(&input)
+ .unwrap()
+ .unwrap();
+ assert_eq!(
+ res,
+ Datum::new(data_type, PrimitiveLiteral::Int128(expected)),
+ "input: {input:?}"
+ );
+ }
+ }
+
+ #[test]
+ fn test_binary_literal() {
Review Comment:
it's included in this pr as well.
--
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]