Skip to content

Commit 3d8c338

Browse files
author
Devdutt Shenoi
committed
spinoff #1251
1 parent b108f92 commit 3d8c338

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/event/format/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ pub trait EventFormat: Sized {
187187
rb = replace_columns(
188188
rb.schema(),
189189
&rb,
190-
&[(0, Arc::new(get_timestamp_array(p_timestamp, rb.num_rows())))],
190+
&[0],
191+
&[Arc::new(get_timestamp_array(p_timestamp, rb.num_rows()))],
191192
);
192193

193194
Ok(rb)

src/utils/arrow/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,21 @@ use serde_json::{Map, Value};
6161
///
6262
/// * `schema` - The schema of the record batch.
6363
/// * `batch` - The record batch to modify.
64-
/// * `indexed_arrays` - A list of indexes and arrays to replace the columns indexed with.
64+
/// * `indexes` - The indexes of the columns to replace.
65+
/// * `arrays` - The new arrays to replace the columns with.
6566
///
6667
/// # Returns
6768
///
6869
/// The modified record batch with the columns replaced.
6970
pub fn replace_columns(
7071
schema: Arc<Schema>,
7172
batch: &RecordBatch,
72-
indexed_arrays: &[(usize, Arc<dyn Array + 'static>)],
73+
indexes: &[usize],
74+
arrays: &[Arc<dyn Array + 'static>],
7375
) -> RecordBatch {
7476
let mut batch_arrays = batch.columns().iter().map(Arc::clone).collect_vec();
75-
for (index, arr) in indexed_arrays {
76-
batch_arrays[*index] = Arc::clone(arr);
77+
for (&index, arr) in indexes.iter().zip(arrays.iter()) {
78+
batch_arrays[index] = Arc::clone(arr);
7779
}
7880
RecordBatch::try_new(schema, batch_arrays).unwrap()
7981
}
@@ -176,7 +178,7 @@ mod tests {
176178

177179
let arr: Arc<dyn Array + 'static> = Arc::new(Int32Array::from_value(0, 3));
178180

179-
let new_rb = replace_columns(schema_ref.clone(), &rb, &[(2, arr)]);
181+
let new_rb = replace_columns(schema_ref.clone(), &rb, &[2], &[arr]);
180182

181183
assert_eq!(new_rb.schema(), schema_ref);
182184
assert_eq!(new_rb.num_columns(), 3);

0 commit comments

Comments
 (0)