Xuanwo commented on code in PR #795: URL: https://github.com/apache/iceberg-rust/pull/795#discussion_r1887090289
########## crates/iceberg/src/spec/values.rs: ########## @@ -3604,4 +3608,29 @@ mod tests { assert_eq!(result, expected); } + + #[test] + fn test_record_ser_de() { + let expected_literal = Literal::Struct(Struct::from_iter(vec![ + Some(Literal::Primitive(PrimitiveLiteral::Int(1))), + Some(Literal::Primitive(PrimitiveLiteral::String( + "bar".to_string(), + ))), + None, + Some(Literal::Primitive(PrimitiveLiteral::Int(1000))), + ])); + let fields = Type::Struct(StructType::new(vec![ + NestedField::required(2, "id", Type::Primitive(PrimitiveType::Int)).into(), + NestedField::optional(3, "name", Type::Primitive(PrimitiveType::String)).into(), + NestedField::optional(4, "address", Type::Primitive(PrimitiveType::String)).into(), + NestedField::required(5, "extra", Type::Primitive(PrimitiveType::Int)).into(), + ])); + + let raw_literal = RawLiteral::try_from(expected_literal.clone(), &fields).unwrap(); + let serialized = serde_json::to_string(&raw_literal).unwrap(); + let deserialized: RawLiteral = serde_json::from_str(&serialized).unwrap(); + let deserialized_literal = deserialized.try_into(&fields).unwrap().unwrap(); + + assert_eq!(expected_literal, deserialized_literal); Review Comment: Mark unresolve for my newly added comment: https://github.com/apache/iceberg-rust/pull/795#discussion_r1887077718 Sorry @Fokko :smile: -- 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