liurenjie1024 commented on code in PR #665: URL: https://github.com/apache/iceberg-rust/pull/665#discussion_r1804486414
########## crates/iceberg/src/spec/values.rs: ########## @@ -3031,6 +3061,31 @@ mod tests { check_avro_bytes_serde(bytes, Datum::string("iceberg"), &PrimitiveType::String); } + #[test] + fn avro_bytes_decimal() { Review Comment: Could we check add more tests for different precision? ########## crates/iceberg/src/spec/values.rs: ########## @@ -449,7 +456,30 @@ impl Datum { PrimitiveLiteral::String(val) => ByteBuf::from(val.as_bytes()), PrimitiveLiteral::UInt128(val) => ByteBuf::from(val.to_be_bytes()), PrimitiveLiteral::Binary(val) => ByteBuf::from(val.as_slice()), - PrimitiveLiteral::Int128(_) => todo!(), + PrimitiveLiteral::Int128(val) => { + let PrimitiveType::Decimal { precision, .. } = self.r#type else { + unreachable!( Review Comment: Should we return error here? ########## crates/iceberg/src/spec/values.rs: ########## @@ -449,7 +456,30 @@ impl Datum { PrimitiveLiteral::String(val) => ByteBuf::from(val.as_bytes()), PrimitiveLiteral::UInt128(val) => ByteBuf::from(val.to_be_bytes()), PrimitiveLiteral::Binary(val) => ByteBuf::from(val.as_slice()), - PrimitiveLiteral::Int128(_) => todo!(), + PrimitiveLiteral::Int128(val) => { + let PrimitiveType::Decimal { precision, .. } = self.r#type else { + unreachable!( + "PrimitiveLiteral Int128 must be PrimitiveType Decimal but got {}", + &self.r#type + ) + }; + + // It's required by iceberg spec that we must keep the minimum + // number of bytes for the value + let required_bytes = Type::decimal_required_bytes(precision) + .expect("PrimitiveType must has valid precision") Review Comment: Ditto. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org