@@ -195,7 +195,7 @@ mod tests {
195195
196196 use arrow:: array:: UInt32Array ;
197197 use arrow:: array:: {
198- Array , BooleanArray , Decimal32Array , Decimal64Array , Decimal128Array ,
198+ Array , AsArray , BooleanArray , Decimal32Array , Decimal64Array , Decimal128Array ,
199199 Decimal256Array , FixedSizeBinaryArray , Int32Array , Int64Array ,
200200 IntervalDayTimeArray , IntervalMonthDayNanoArray , IntervalYearMonthArray ,
201201 StringArray ,
@@ -506,6 +506,39 @@ mod tests {
506506 Ok ( ( ) )
507507 }
508508
509+ #[ test]
510+ fn fixed_size_binary_16_common_prefix ( ) -> Result < ( ) > {
511+ let first = [ 0xa5_u8 ; 16 ] ;
512+ let mut second = first;
513+ second[ 15 ] = 0xa6 ;
514+ let schema = Arc :: new ( Schema :: new ( vec ! [
515+ Field :: new( "a" , DataType :: Int32 , false ) ,
516+ Field :: new( "b" , DataType :: FixedSizeBinary ( 16 ) , false ) ,
517+ ] ) ) ;
518+ let mut clustered = GroupValuesClustered :: try_new ( Arc :: clone ( & schema) ) ?;
519+ let mut hashed = GroupValuesColumn :: < true > :: try_new ( schema) ?;
520+ let mut actual = Vec :: new ( ) ;
521+ let mut expected = Vec :: new ( ) ;
522+ // Continue the first group, then distinguish a key only by its last byte.
523+ for ( key, group_id) in [ ( first, 0 ) , ( first, 0 ) , ( second, 1 ) ] {
524+ let batch: [ ArrayRef ; 2 ] = [
525+ Arc :: new ( Int32Array :: from ( vec ! [ 7 ] ) ) ,
526+ Arc :: new ( FixedSizeBinaryArray :: try_from_iter ( [ key] . into_iter ( ) ) ?) ,
527+ ] ;
528+ clustered. intern ( & batch, & mut actual) ?;
529+ hashed. intern ( & batch, & mut expected) ?;
530+ assert_eq ! ( actual, [ group_id] ) ;
531+ assert_eq ! ( actual, expected) ;
532+ }
533+ let values = clustered. emit ( EmitTo :: All ) ?;
534+ assert_eq ! ( values, hashed. emit( EmitTo :: All ) ?) ;
535+ assert_eq ! (
536+ values[ 1 ] . as_fixed_size_binary( ) . value_data( ) ,
537+ [ first, second] . concat( )
538+ ) ;
539+ Ok ( ( ) )
540+ }
541+
509542 #[ test]
510543 fn zero_width_binary_preserves_emitted_lengths_and_nulls ( ) -> Result < ( ) > {
511544 for nullable in [ false , true ] {
0 commit comments