Skip to content

Commit

Permalink
Use prep_null_mask_filter to handle nulls in selection mask
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Feb 8, 2024
1 parent 10e6d18 commit 7c30fb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion datafusion/physical-plan/src/joins/sort_merge_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,14 @@ impl SMJStream {
) {
// The reverse of the selection mask. For the rows not pass join filter above,
// we need to join them (left or right) with null rows for outer joins.
let not_mask = compute::not(mask)?;
let not_mask = if mask.null_count() > 0 {
// If the mask contains nulls, we need to use `prep_null_mask_filter` to
// handle the nulls in the mask as false.
compute::not(&compute::prep_null_mask_filter(mask))?
} else {
compute::not(mask)?
};

let null_joined_batch =
compute::filter_record_batch(&output_batch, &not_mask)?;

Expand Down
1 change: 1 addition & 0 deletions datafusion/sqllogictest/test_files/sort_merge_join.slt
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ SELECT * FROM t1 FULL JOIN t2 ON t1_id = t2_id AND t2_int <= t1_int
44 d 4 44 x 3
NULL NULL NULL 11 z 3
NULL NULL NULL 55 w 3
NULL NULL NULL NULL NULL NULL

statement ok
DROP TABLE t1;
Expand Down

0 comments on commit 7c30fb2

Please sign in to comment.