Skip to content

Commit

Permalink
fix(batch): fix batch left outer join with equal condition (#17797) (#…
Browse files Browse the repository at this point in the history
…17800)

Co-authored-by: Dylan <[email protected]>
Co-authored-by: lmatz <[email protected]>
  • Loading branch information
3 people authored Jul 24, 2024
1 parent fd40d91 commit c87ac64
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/batch/src/executor/join/hash_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,6 @@ impl<K: HashKey> HashJoinExecutor<K> {
if !visible {
continue;
}
non_equi_state.found_matched = false;
if let Some(first_matched_build_row_id) = hash_map.get(probe_key) {
non_equi_state
.first_output_row_id
Expand Down Expand Up @@ -1992,13 +1991,17 @@ impl DataChunkMutator {
new_visibility.set(row_id, true);
}
}
if !has_more_output_rows && !*found_non_null {
new_visibility.set(start_row_id, true);
if !has_more_output_rows {
if !*found_non_null {
new_visibility.set(start_row_id, true);
}
*found_non_null = false;
}

first_output_row_ids.clear();

self.0.set_visibility(new_visibility.finish());
self.0
.set_visibility(new_visibility.finish() & self.0.visibility());
self
}

Expand Down Expand Up @@ -3218,14 +3221,15 @@ mod tests {
3 5.0 3 4.0
3 5.0 3 3.0
4 1.0 4 0
4 1.0 4 0.5",
4 1.0 4 9.0",
);
let expect = DataChunk::from_pretty(
"i f i F
1 3.5 1 5.5
2 4.0 . .
3 5.0 . .
3 5.0 . .",
3 5.0 . .
4 1.0 4 9.0",
);
let cond = TestFixture::create_cond();
let mut state = LeftNonEquiJoinState {
Expand All @@ -3246,7 +3250,7 @@ mod tests {
&expect
));
assert_eq!(state.first_output_row_id, Vec::<usize>::new());
assert!(!state.found_matched);
assert!(state.found_matched);

let chunk = DataChunk::from_pretty(
"i f i F
Expand Down Expand Up @@ -3306,7 +3310,7 @@ mod tests {
&expect
));
assert_eq!(state.first_output_row_id, Vec::<usize>::new());
assert!(state.found_matched);
assert!(!state.found_matched);
}

#[tokio::test]
Expand Down

0 comments on commit c87ac64

Please sign in to comment.