@@ -202,8 +202,7 @@ impl ArrowReader {
202
202
203
203
// Create a projection mask for the batch stream to select which columns in the
204
204
// Parquet file that we want in the response
205
- // Since Parquet projection mask will lose the order of the columns, we need to reorder.
206
- let ( projection_mask, reorder) = Self :: get_arrow_projection_mask (
205
+ let projection_mask = Self :: get_arrow_projection_mask (
207
206
& task. project_field_ids ,
208
207
& task. schema ,
209
208
record_batch_stream_builder. parquet_schema ( ) ,
@@ -271,11 +270,6 @@ impl ArrowReader {
271
270
let mut record_batch_stream = record_batch_stream_builder. build ( ) ?;
272
271
273
272
while let Some ( batch) = record_batch_stream. try_next ( ) . await ? {
274
- let batch = if let Some ( reorder) = reorder. as_ref ( ) {
275
- batch. project ( & reorder) . expect ( "must be able to reorder" )
276
- } else {
277
- batch
278
- } ;
279
273
tx. send ( record_batch_transformer. process_record_batch ( batch) )
280
274
. await ?
281
275
}
@@ -304,9 +298,9 @@ impl ArrowReader {
304
298
iceberg_schema_of_task : & Schema ,
305
299
parquet_schema : & SchemaDescriptor ,
306
300
arrow_schema : & ArrowSchemaRef ,
307
- ) -> Result < ( ProjectionMask , Option < Vec < usize > > ) > {
301
+ ) -> Result < ProjectionMask > {
308
302
if field_ids. is_empty ( ) {
309
- Ok ( ( ProjectionMask :: all ( ) , None ) )
303
+ Ok ( ProjectionMask :: all ( ) )
310
304
} else {
311
305
// Build the map between field id and column index in Parquet schema.
312
306
let mut column_map = HashMap :: new ( ) ;
@@ -364,20 +358,7 @@ impl ArrowReader {
364
358
) ) ;
365
359
}
366
360
}
367
-
368
- // projection mask is order by indices
369
- let mut mask_indices = indices. clone ( ) ;
370
- mask_indices. sort_by_key ( |& x| x) ;
371
- // try to reorder the mask_indices to indices
372
- let reorder = indices
373
- . iter ( )
374
- . map ( |idx| mask_indices. iter ( ) . position ( |& i| i == * idx) . unwrap ( ) )
375
- . collect :: < Vec < _ > > ( ) ;
376
-
377
- Ok ( (
378
- ProjectionMask :: roots ( parquet_schema, indices) ,
379
- Some ( reorder) ,
380
- ) )
361
+ Ok ( ProjectionMask :: roots ( parquet_schema, indices) )
381
362
}
382
363
}
383
364
0 commit comments