You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/05/25 16:29:49 UTC

[GitHub] [arrow-datafusion] korowa commented on a diff in pull request #2591: Support for non equality predicates in `ON` clause of `LEFT`, `RIGHT, `and `FULL` joins

korowa commented on code in PR #2591:
URL: https://github.com/apache/arrow-datafusion/pull/2591#discussion_r881870265


##########
datafusion/core/src/physical_plan/hash_join.rs:
##########
@@ -791,6 +826,109 @@ fn build_join_indexes(
     }
 }
 
+fn apply_join_filter(
+    left: &RecordBatch,
+    right: &RecordBatch,
+    join_type: JoinType,
+    left_indices: UInt64Array,
+    right_indices: UInt32Array,
+    filter: &JoinFilter,
+) -> Result<(UInt64Array, UInt32Array)> {
+    if left_indices.is_empty() {
+        return Ok((left_indices, right_indices));
+    };
+
+    let (intermediate_batch, _) = build_batch_from_indices(
+        filter.schema(),
+        left,
+        right,
+        PrimitiveArray::from(left_indices.data().clone()),
+        PrimitiveArray::from(right_indices.data().clone()),
+        filter.column_indices(),
+    )?;
+
+    match join_type {
+        JoinType::Inner | JoinType::Left => {
+            // For both INNER and LEFT joins, input arrays contains only indices for matched data.

Review Comment:
   That was my initial plan, but it turned out there are [no nulls appended](https://github.com/apache/arrow-datafusion/blob/8e71c887621254b3d18523ad182045a9e987ee12/datafusion/core/src/physical_plan/hash_join.rs#L728) in case of left join while building matched indices. All null values are handled [later](https://github.com/apache/arrow-datafusion/blob/8e71c887621254b3d18523ad182045a9e987ee12/datafusion/core/src/physical_plan/hash_join.rs#L1024), using visited left side indices



-- 
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-unsubscribe@arrow.apache.org

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