Skip to content
Merged
Changes from all commits
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
14 changes: 6 additions & 8 deletions vortex-array/src/array/struct_/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use vortex_scalar::Scalar;
use crate::array::struct_::StructArray;
use crate::compute::unary::{scalar_at, scalar_at_unchecked, ScalarAtFn};
use crate::compute::{filter, slice, take, ArrayCompute, FilterFn, SliceFn, TakeFn};
use crate::stats::ArrayStatistics;
use crate::variants::StructArrayTrait;
use crate::{Array, ArrayDType, IntoArray};

Expand Down Expand Up @@ -79,20 +78,19 @@ impl SliceFn for StructArray {

impl FilterFn for StructArray {
fn filter(&self, predicate: &Array) -> VortexResult<Array> {
let fields = self
let fields: Vec<Array> = self
.children()
.map(|field| filter(&field, predicate))
.try_collect()?;

let predicate_true_count = predicate
.statistics()
.compute_true_count()
.ok_or_else(|| vortex_err!("Predicate should always be a boolean array"))?;
let length = fields
.first()
.map(|a| a.len())
.ok_or_else(|| vortex_err!("Struct arrays should have at least one field"))?;

Self::try_new(
self.names().clone(),
fields,
predicate_true_count,
length,
self.validity().filter(predicate)?,
)
.map(|a| a.into_array())
Expand Down