fix: drop useless clone and for loop second (#5507)

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
yihong
2025-02-11 14:23:49 +08:00
committed by GitHub
parent d094f48822
commit de3f817596

View File

@@ -498,13 +498,13 @@ fn interleave_batches(
}
// interleave arrays
let mut interleaved_arrays = Vec::with_capacity(arrays.len());
for array in arrays {
interleaved_arrays.push(compute::interleave(&array, &indices)?);
}
let interleaved_arrays: Vec<_> = arrays
.into_iter()
.map(|array| compute::interleave(&array, &indices))
.collect::<Result<_, _>>()?;
// assemble new record batch
RecordBatch::try_new(schema.clone(), interleaved_arrays)
RecordBatch::try_new(schema, interleaved_arrays)
.map_err(|e| DataFusionError::ArrowError(e, None))
}