ZENOTME commented on code in PR #795:
URL: https://github.com/apache/iceberg-rust/pull/795#discussion_r1887057758


##########
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:
   This is not same as JSON single-value serialization, th JSON single-value 
serialization has the specific implementation 
https://github.com/apache/iceberg-rust/blob/813c2b5610490886e819be97fb5fbf173ad68a58/crates/iceberg/src/spec/values.rs#L1993.
   This test case is just to test the normal Serialize implementation, 
internally it mainly used in avro format. See 
https://docs.rs/avro-rs/latest/avro_rs/types/struct.Record.html, that's why 
here record store name and value. 
   
   Here I serialize it into json type is to test the reorder case.



-- 
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

Reply via email to