Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Special-case filter single array record batch in filter_record_batch #235

Merged
merged 3 commits into from
Jul 30, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/compute/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,21 @@ pub fn filter_record_batch(
record_batch: &RecordBatch,
filter: &BooleanArray,
) -> Result<RecordBatch> {
let filter = build_filter(filter)?;
let filtered_arrays = record_batch
.columns()
.iter()
.map(|a| filter(a.as_ref()).into())
.collect();
let num_colums = record_batch.columns().len();

let filtered_arrays = match num_colums {
1 => {
vec![super::filter::filter(record_batch.columns()[0].as_ref(), filter)?.into()]
Dandandan marked this conversation as resolved.
Show resolved Hide resolved
}
_ => {
let filter = build_filter(filter)?;
record_batch
.columns()
.iter()
.map(|a| filter(a.as_ref()).into())
.collect()
}
};
RecordBatch::try_new(record_batch.schema().clone(), filtered_arrays)
}

Expand Down