@@ -820,18 +820,29 @@ mod tests {
820820
821821 /// Spark hashes a float through `doubleToLongBits` or `floatToIntBits`, which canonicalize
822822 /// NaN, so a NaN with the sign bit set or with a payload hashes like the canonical NaN inside
823- /// lists, structs and dictionaries too. Checks both hashes, which expand the same macros.
823+ /// lists, structs, maps and dictionaries too. Checks both hashes, which expand the same macros.
824824 #[ test]
825825 fn test_non_canonical_nan_hashes_like_canonical_nan ( ) {
826826 use crate :: hash_funcs:: create_xxhash64_hashes;
827827 use arrow:: array:: {
828- DictionaryArray , FixedSizeListArray , Int32Array , LargeListArray , ListArray , StructArray ,
828+ DictionaryArray , FixedSizeListArray , Int32Array , LargeListArray , ListArray , MapArray ,
829+ StructArray ,
829830 } ;
830831 use arrow:: buffer:: OffsetBuffer ;
831- use arrow:: datatypes:: Field ;
832+ use arrow:: datatypes:: { DataType , Field , Fields } ;
832833
833834 let shapes = |values : ArrayRef | -> Vec < ArrayRef > {
834835 let field = Arc :: new ( Field :: new ( "item" , values. data_type ( ) . clone ( ) , true ) ) ;
836+ // One entry per row, with the float as both the key and the value.
837+ let entry_fields = Fields :: from ( vec ! [
838+ Field :: new( "key" , values. data_type( ) . clone( ) , false ) ,
839+ Field :: new( "value" , values. data_type( ) . clone( ) , true ) ,
840+ ] ) ;
841+ let entries = StructArray :: new (
842+ entry_fields. clone ( ) ,
843+ vec ! [ Arc :: clone( & values) , Arc :: clone( & values) ] ,
844+ None ,
845+ ) ;
835846 vec ! [
836847 Arc :: clone( & values) ,
837848 Arc :: new( ListArray :: new(
@@ -861,6 +872,13 @@ mod tests {
861872 Int32Array :: from( vec![ 0 , 1 , 2 ] ) ,
862873 values,
863874 ) ) ,
875+ Arc :: new( MapArray :: new(
876+ Arc :: new( Field :: new( "entries" , DataType :: Struct ( entry_fields) , false ) ) ,
877+ OffsetBuffer :: from_lengths( [ 1 ; 3 ] ) ,
878+ entries,
879+ None ,
880+ false ,
881+ ) ) ,
864882 ]
865883 } ;
866884 let canonical64: ArrayRef = Arc :: new ( Float64Array :: from ( vec ! [ f64 :: NAN ; 3 ] ) ) ;
0 commit comments