metesynnada commented on code in PR #6724:
URL: https://github.com/apache/arrow-datafusion/pull/6724#discussion_r1236474277
##########
datafusion/core/src/physical_plan/joins/hash_join.rs:
##########
@@ -1097,6 +1098,49 @@ pub fn equal_rows(
err.unwrap_or(Ok(res))
}
+fn eq_dyn_null(
+ left: &dyn Array,
+ right: &dyn Array,
+ null_equals_null: bool,
+) -> Result<BooleanArray, ArrowError> {
+ match (left.data_type(), right.data_type()) {
+ (DataType::Null, DataType::Null) => Ok(BooleanArray::new(
+ BooleanBuffer::collect_bool(left.len(), |_| null_equals_null),
+ None,
+ )),
+ _ => eq_dyn(left, right),
+ }
+}
+
+pub fn equal_rows_arr(
+ indices_left: UInt64Array,
+ indices_right: UInt32Array,
+ left_arrays: &[ArrayRef],
+ right_arrays: &[ArrayRef],
+ null_equals_null: bool,
Review Comment:
```rust
pub fn equal_rows_arr(
indices_left: UInt64Array,
indices_right: UInt32Array,
left_arrays: &[ArrayRef],
right_arrays: &[ArrayRef],
null_equals_null: bool,
) -> Result<(UInt64Array, UInt32Array)> {
// Create an iterator that yields pairs of items from left_arrays and
right_arrays.
let mut iter = left_arrays.iter().zip(right_arrays.iter());
// Get the first pair of arrays (or error if the iterators are empty).
let (first_left, first_right) = iter.next().ok_or_else(|| {
DataFusionError::Internal("At least one array should be provided for
both left and right".to_string())
})?;
// Use the take function on the first pair of arrays and the respective
indices.
let arr_left = take(first_left.as_ref(), &indices_left, None)?;
let arr_right = take(first_right.as_ref(), &indices_right, None)?;
// Determine whether the first pair of arrays are equal, considering
nulls as defined by null_equals_null.
let mut equal = eq_dyn_null(&arr_left, &arr_right, null_equals_null)?;
// Use map and try_fold to iterate over the remaining pairs of arrays.
// In each iteration, take is used on the pair of arrays and their
equality is determined.
// The results are then folded (combined) using the and function to get
a final equality result.
equal = iter
.map(|(left, right)| {
let arr_left = take(left.as_ref(), &indices_left, None)?;
let arr_right = take(right.as_ref(), &indices_right, None)?;
eq_dyn_null(arr_left.as_ref(), arr_right.as_ref(),
null_equals_null)
})
.try_fold(equal, |acc, res| {
let equal2 = res?;
and(&acc, &equal2)
})?;
// Continue
}
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]