Skip to content

Commit

Permalink
use as_struct & collect.
Browse files Browse the repository at this point in the history
  • Loading branch information
my-vegetable-has-exploded committed Dec 18, 2023
1 parent d9783dc commit 73f2a56
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions arrow-ord/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use arrow_array::cast::AsArray;
use arrow_array::types::ByteArrayType;
use arrow_array::{
downcast_primitive_array, AnyDictionaryArray, Array, ArrowNativeTypeOp, BooleanArray, Datum,
FixedSizeBinaryArray, GenericByteArray, StructArray,
FixedSizeBinaryArray, GenericByteArray,
};
use arrow_buffer::bit_util::ceil;
use arrow_buffer::{BooleanBuffer, MutableBuffer, NullBuffer};
Expand Down Expand Up @@ -335,20 +335,17 @@ fn compare_op_struct_values(
_ => unreachable!(),
};

let l = l.as_any().downcast_ref::<StructArray>().unwrap();
let r = r.as_any().downcast_ref::<StructArray>().unwrap();
let l = l.as_struct();
let r = r.as_struct();

let mut child_res: Vec<BooleanBuffer> = Vec::with_capacity(len);
// compare each field of struct
for item in l
let child_res = l
.columns()
.to_vec()
.iter()
.zip(r.columns().to_vec().iter())
.map(|(col_l, col_r)| compare_op_values(Op::Equal, col_l, l_s, col_r, r_s, len))
{
child_res.push(item?);
}
.collect::<Result<Vec<BooleanBuffer>, ArrowError>>()?;
// combine the result of each field
let equality = child_res
.iter()
Expand Down

0 comments on commit 73f2a56

Please sign in to comment.