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
  • Loading branch information
chenzl25 authored Jul 24, 2024
1 parent 3087eec commit f2fe044
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 @@ -907,7 +907,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 @@ -2018,13 +2017,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 @@ -3316,14 +3319,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 @@ -3344,7 +3348,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 @@ -3404,7 +3408,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 f2fe044

Please sign in to comment.