tustvold commented on code in PR #5423:
URL: https://github.com/apache/arrow-rs/pull/5423#discussion_r1501284691


##########
arrow-ord/src/cmp.rs:
##########
@@ -198,7 +198,38 @@ fn compare_op(op: Op, lhs: &dyn Datum, rhs: &dyn Datum) -> 
Result<BooleanArray,
     let r = r_v.map(|x| x.values().as_ref()).unwrap_or(r);
     let r_t = r.data_type();
 
-    if l_t != r_t || l_t.is_nested() {
+    if l_t != r_t {
+        return Err(ArrowError::InvalidArgumentError(format!(
+            "Invalid comparison operation: {l_t} {op} {r_t}"
+        )));
+    }
+
+    if let Struct(_) = l_t {
+        let l = l.as_struct();
+        let r = r.as_struct();
+        assert_eq!(l.num_columns(), r.num_columns());
+        match op {
+            Op::Equal => {
+                let mut res = vec![true; len];
+                for i in 0..l.num_columns() {
+                    let col_l = l.column(i);
+                    let col_r = r.column(i);
+                    let eq_rows = compare_op(op, col_l, col_r)?;
+                    for (j, item) in res.iter_mut().enumerate().take(len) {

Review Comment:
   It will be faster to compute the bitwise and of the underlying buffers, than 
to do this element wise
   
   Something like
   
   ```
   let nulls = NullBuffer::union(l.nulls(), r.nulls());
   let vals = l.values () & r.values();
   BooleanArray::new(vals, nulls)
   ```
   
   In combination with `Iterator::fold`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to