@@ -579,11 +579,13 @@ impl ByteArrayDecoderDictionary {
579
579
#[ cfg( test) ]
580
580
mod tests {
581
581
use super :: * ;
582
+ use crate :: arrow:: record_reader:: buffer:: ValuesBuffer ;
582
583
use crate :: basic:: Type as PhysicalType ;
583
584
use crate :: data_type:: { ByteArray , ByteArrayType } ;
584
585
use crate :: encodings:: encoding:: { get_encoder, DictEncoder , Encoder } ;
585
586
use crate :: schema:: types:: { ColumnDescriptor , ColumnPath , Type } ;
586
587
use crate :: util:: memory:: MemTracker ;
588
+ use arrow:: array:: { Array , StringArray } ;
587
589
use std:: sync:: Arc ;
588
590
589
591
fn column ( ) -> ColumnDescPtr {
@@ -664,6 +666,34 @@ mod tests {
664
666
assert_eq ! ( output. offsets. as_slice( ) , & [ 0 , 5 , 10 , 11 , 12 ] ) ;
665
667
666
668
assert_eq ! ( decoder. read( & mut output, 4 ..8 ) . unwrap( ) , 0 ) ;
669
+
670
+ let valid = vec ! [ false , false , true , true , false , true , true , false , false ] ;
671
+ let rev_position_iter = valid
672
+ . iter ( )
673
+ . enumerate ( )
674
+ . rev ( )
675
+ . filter_map ( |( i, valid) | valid. then ( || i) ) ;
676
+
677
+ let valid_buffer = Buffer :: from_iter ( valid. iter ( ) . cloned ( ) ) ;
678
+
679
+ output. pad_nulls ( 0 , 4 , valid. len ( ) , rev_position_iter) ;
680
+ let array = output. into_array ( Some ( valid_buffer) , ArrowType :: Utf8 ) ;
681
+ let strings = array. as_any ( ) . downcast_ref :: < StringArray > ( ) . unwrap ( ) ;
682
+
683
+ assert_eq ! (
684
+ strings. iter( ) . collect:: <Vec <_>>( ) ,
685
+ vec![
686
+ None ,
687
+ None ,
688
+ Some ( "hello" ) ,
689
+ Some ( "world" ) ,
690
+ None ,
691
+ Some ( "a" ) ,
692
+ Some ( "b" ) ,
693
+ None ,
694
+ None ,
695
+ ]
696
+ ) ;
667
697
}
668
698
}
669
699
}
0 commit comments