Skip to content

Commit 8c486d6

Browse files
committed
Revert "reorder record batch"
This reverts commit 66d7c4a.
1 parent c26805d commit 8c486d6

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

crates/iceberg/src/arrow/reader.rs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ impl ArrowReader {
202202

203203
// Create a projection mask for the batch stream to select which columns in the
204204
// 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(
207206
&task.project_field_ids,
208207
&task.schema,
209208
record_batch_stream_builder.parquet_schema(),
@@ -271,11 +270,6 @@ impl ArrowReader {
271270
let mut record_batch_stream = record_batch_stream_builder.build()?;
272271

273272
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-
};
279273
tx.send(record_batch_transformer.process_record_batch(batch))
280274
.await?
281275
}
@@ -304,9 +298,9 @@ impl ArrowReader {
304298
iceberg_schema_of_task: &Schema,
305299
parquet_schema: &SchemaDescriptor,
306300
arrow_schema: &ArrowSchemaRef,
307-
) -> Result<(ProjectionMask, Option<Vec<usize>>)> {
301+
) -> Result<ProjectionMask> {
308302
if field_ids.is_empty() {
309-
Ok((ProjectionMask::all(), None))
303+
Ok(ProjectionMask::all())
310304
} else {
311305
// Build the map between field id and column index in Parquet schema.
312306
let mut column_map = HashMap::new();
@@ -364,20 +358,7 @@ impl ArrowReader {
364358
));
365359
}
366360
}
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))
381362
}
382363
}
383364

0 commit comments

Comments
 (0)