Fokko commented on code in PR #795: URL: https://github.com/apache/iceberg-rust/pull/795#discussion_r1887570509
########## 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: Ah, around the same time! I share your concern, and I would like to check later on if we do the field-ID projection properly, but I didn't want to block the release 👍 For Avro it is very simple, it will always be decoded in the same order as the schema (otherwise it will just break). That said, we can rely on the order for V1, but use field-ID-based projection for V2 tables. -- 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