Fokko commented on code in PR #795: URL: https://github.com/apache/iceberg-rust/pull/795#discussion_r1886917197
########## 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: It looks like the whole serialization is off, this should be [done by ID](https://iceberg.apache.org/spec/?column-projection#json-single-value-serialization) instead of name: I checked out the branch, and it is currently by name: ```json { "id": 1, "extra": 1000, "name": "bar", "address": null } ``` While it should be: ```json { "2": 1, "3": "bar", "4": null, "5": 1000 } ``` -- 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