From 73f2a5672e4d6980d24d1524c29c696d216b3c6d Mon Sep 17 00:00:00 2001 From: my-vegetable-has-exploded Date: Mon, 18 Dec 2023 23:08:38 +0800 Subject: [PATCH] use as_struct & collect. --- arrow-ord/src/cmp.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arrow-ord/src/cmp.rs b/arrow-ord/src/cmp.rs index b235548c17d9..746bcba7cd95 100644 --- a/arrow-ord/src/cmp.rs +++ b/arrow-ord/src/cmp.rs @@ -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}; @@ -335,20 +335,17 @@ fn compare_op_struct_values( _ => unreachable!(), }; - let l = l.as_any().downcast_ref::().unwrap(); - let r = r.as_any().downcast_ref::().unwrap(); + let l = l.as_struct(); + let r = r.as_struct(); - let mut child_res: Vec = 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::, ArrowError>>()?; // combine the result of each field let equality = child_res .iter()