@@ -101,10 +101,10 @@ fn take_map<I: IntegerPType, V: NativePType>(
101101
102102 // Now, iterate the take indices using the prebuilt hashmap.
103103 // Undefined/null indices will miss the hash map, which we can ignore.
104- for index in indices {
104+ for ( output_index , index) in indices. iter ( ) . enumerate ( ) {
105105 let index = index. as_ ( ) ;
106106 if let Some ( & patch_value) = index_map. get ( & index) {
107- output[ index ] = patch_value;
107+ output[ output_index ] = patch_value;
108108 }
109109 }
110110}
@@ -150,7 +150,7 @@ mod tests {
150150
151151 // Take indices [0, 1, 2, 3, 4] - should get [0, 10, 0, 30, 0]
152152 let indices = buffer ! [ 0u32 , 1 , 2 , 3 , 4 ] . into_array ( ) ;
153- let result = array. take ( indices) ?;
153+ let result = array. take ( indices) ?. to_canonical ( ) ? . into_array ( ) ;
154154
155155 let expected = PrimitiveArray :: from_iter ( [ 0u16 , 10 , 0 , 30 , 0 ] ) . into_array ( ) ;
156156 assert_arrays_eq ! ( expected, result) ;
@@ -165,7 +165,7 @@ mod tests {
165165
166166 // Take indices in reverse order
167167 let indices = buffer ! [ 4u32 , 3 , 2 , 1 , 0 ] . into_array ( ) ;
168- let result = array. take ( indices) ?;
168+ let result = array. take ( indices) ?. to_canonical ( ) ? . into_array ( ) ;
169169
170170 let expected = PrimitiveArray :: from_iter ( [ 0u16 , 30 , 0 , 10 , 0 ] ) . into_array ( ) ;
171171 assert_arrays_eq ! ( expected, result) ;
@@ -180,7 +180,10 @@ mod tests {
180180
181181 // Take the same patched index multiple times
182182 let indices = buffer ! [ 2u32 , 2 , 0 , 2 ] . into_array ( ) ;
183- let result = array. take ( indices) ?;
183+ let result = array. take ( indices) ?. to_canonical ( ) ?. into_array ( ) ;
184+
185+ // execute the array.
186+ let _canonical = result. to_canonical ( ) ?. into_primitive ( ) ;
184187
185188 let expected = PrimitiveArray :: from_iter ( [ 99u16 , 99 , 0 , 99 ] ) . into_array ( ) ;
186189 assert_arrays_eq ! ( expected, result) ;
@@ -211,7 +214,10 @@ mod tests {
211214 . into_array ( ) ,
212215 ) ,
213216 ) ;
214- let result = array. take ( indices. into_array ( ) ) ?;
217+ let result = array
218+ . take ( indices. into_array ( ) ) ?
219+ . to_canonical ( ) ?
220+ . into_array ( ) ;
215221
216222 // Expected: [0, 20, null, 50, 80, null, 50, 80, null, 0]
217223 let expected = PrimitiveArray :: new (
0 commit comments