friendlymatthew commented on code in PR #7943:
URL: https://github.com/apache/arrow-rs/pull/7943#discussion_r2212607373


##########
parquet-variant/src/variant/object.rs:
##########
@@ -387,6 +389,31 @@ impl<'m, 'v> VariantObject<'m, 'v> {
     }
 }
 
+impl<'m, 'v> PartialEq for VariantObject<'m, 'v> {
+    fn eq(&self, other: &Self) -> bool {
+        let mut is_equal = self.metadata == other.metadata
+            && self.header == other.header
+            && self.num_elements == other.num_elements
+            && self.first_field_offset_byte == other.first_field_offset_byte
+            && self.first_value_byte == other.first_value_byte
+            && self.validated == other.validated;
+
+        // value validation

Review Comment:
   Hm, I am not sure if we can compare by field names. 
   
   Here's a test case where two variants have the same field names but 
differing values. The two objects will have the same metadata, but it will fail 
the logical comparison.
   
   ```rs
   fn foo() {
       let mut b = VariantBuilder::new();
       let mut o = b.new_object();
   
       o.insert("a", ());
       o.insert("b", 4.3);
   
       o.finish().unwrap();
   
       let (m, v) = b.finish();
   
       let v1 = Variant::try_new(&m, &v).unwrap();
   
       // second object, same field name but different values
       let mut b = VariantBuilder::new();
       let mut o = b.new_object();
   
       o.insert("a", ());
       let mut inner_o = o.new_object("b");
       inner_o.insert("a", 3.3);
       inner_o.finish().unwrap();
       o.finish().unwrap();
   
       let (m, v) = b.finish();
   
       let v2 = Variant::try_new(&m, &v).unwrap();
   
       let m1 = v1.metadata().unwrap();
       let m2 = v2.metadata().unwrap();
   
       // metadata would be equal since they contain the same keys
       assert_eq!(m1, m2);
   
       // but the objects are not equal
       assert_ne!(v1, v2);
   }
   ```



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to