@@ -127,7 +127,7 @@ impl VariantMetadataHeader {
127
127
///
128
128
/// [`Variant`]: crate::Variant
129
129
/// [Variant Spec]: https://github.com/apache/parquet-format/blob/master/VariantEncoding.md#metadata-encoding
130
- #[ derive( Debug , Clone ) ]
130
+ #[ derive( Debug , Clone , PartialEq ) ]
131
131
pub struct VariantMetadata < ' m > {
132
132
pub ( crate ) bytes : & ' m [ u8 ] ,
133
133
header : VariantMetadataHeader ,
@@ -335,23 +335,6 @@ impl<'m> VariantMetadata<'m> {
335
335
}
336
336
}
337
337
338
- // Metadata dictionaries can be in any order per the spec to allow flexible Variant construction
339
- // This comparison checks for field name presence in both metadata instances rather than raw byte equality
340
- impl < ' m > PartialEq for VariantMetadata < ' m > {
341
- fn eq ( & self , other : & Self ) -> bool {
342
- self . is_empty ( ) == other. is_empty ( )
343
- && if self . is_sorted ( ) && other. is_sorted ( ) {
344
- self . len ( ) == other. len ( ) && self . iter ( ) . eq ( other. iter ( ) )
345
- } else {
346
- // can't guarantee neither field names are unique
347
- let self_field_names: HashSet < & ' m str > = HashSet :: from_iter ( self . iter ( ) ) ;
348
- let other_field_names: HashSet < & ' m str > = HashSet :: from_iter ( other. iter ( ) ) ;
349
-
350
- self_field_names == other_field_names
351
- }
352
- }
353
- }
354
-
355
338
/// Retrieves the ith dictionary entry, panicking if the index is out of bounds. Accessing
356
339
/// [unvalidated] input could also panic if the underlying bytes are invalid.
357
340
///
@@ -586,42 +569,7 @@ mod tests {
586
569
let m2 = VariantMetadata :: try_new ( & metadata_bytes) . unwrap ( ) ;
587
570
assert ! ( !m2. is_sorted( ) ) ;
588
571
589
- assert_eq ! ( m1, m2) ;
590
- }
591
-
592
- #[ test]
593
- fn test_compare_sorted_dictionary_with_unsorted_dictionary2 ( ) {
594
- // create a sorted object
595
- let mut b = VariantBuilder :: new ( ) ;
596
- let mut o = b. new_object ( ) ;
597
-
598
- o. insert ( "a" , false ) ;
599
- o. insert ( "b" , false ) ;
600
-
601
- o. finish ( ) . unwrap ( ) ;
602
-
603
- let ( m, _) = b. finish ( ) ;
604
-
605
- let m1 = VariantMetadata :: new ( & m) ;
606
- assert ! ( m1. is_sorted( ) ) ;
607
-
608
- // Create metadata with an unsorted dictionary (field names are "b", "b", "a")
609
- // Since field names are not unique nor lexicographically ordered, it is considered not sorted.
610
- let metadata_bytes = vec ! [
611
- 0b0000_0001 ,
612
- 3 , // dictionary size
613
- 0 , // "b"
614
- 1 , // "b"
615
- 2 , // "a"
616
- 3 ,
617
- b'b' ,
618
- b'b' ,
619
- b'a' ,
620
- ] ;
621
- let m2 = VariantMetadata :: try_new ( & metadata_bytes) . unwrap ( ) ;
622
- assert ! ( !m2. is_sorted( ) ) ;
623
-
624
- assert_eq ! ( m1, m2) ;
572
+ assert_ne ! ( m1, m2) ;
625
573
}
626
574
627
575
#[ test]
@@ -642,35 +590,4 @@ mod tests {
642
590
643
591
assert_eq ! ( m1, m2) ;
644
592
}
645
-
646
- #[ test]
647
- fn test_compare_sorted_dictionary_with_sorted_dictionary2 ( ) {
648
- // create a sorted object
649
- let mut b = VariantBuilder :: new ( ) ;
650
- let mut o = b. new_object ( ) ;
651
-
652
- o. insert ( "a" , false ) ;
653
- o. insert ( "b" , false ) ;
654
-
655
- o. finish ( ) . unwrap ( ) ;
656
-
657
- let ( m, _) = b. finish ( ) ;
658
-
659
- let m1 = VariantMetadata :: new ( & m) ;
660
-
661
- // create a sorted object with different field names
662
- let mut b = VariantBuilder :: new ( ) ;
663
- let mut o = b. new_object ( ) ;
664
-
665
- o. insert ( "c" , false ) ;
666
- o. insert ( "d" , false ) ;
667
-
668
- o. finish ( ) . unwrap ( ) ;
669
-
670
- let ( m, _) = b. finish ( ) ;
671
-
672
- let m2 = VariantMetadata :: new ( & m) ;
673
-
674
- assert_ne ! ( m1, m2) ;
675
- }
676
593
}
0 commit comments