diff --git a/src/batch/src/executor/join/hash_join.rs b/src/batch/src/executor/join/hash_join.rs index f6440c74430a6..73be5b8892b63 100644 --- a/src/batch/src/executor/join/hash_join.rs +++ b/src/batch/src/executor/join/hash_join.rs @@ -881,7 +881,6 @@ impl HashJoinExecutor { 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 @@ -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 } @@ -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 { @@ -3246,7 +3250,7 @@ mod tests { &expect )); assert_eq!(state.first_output_row_id, Vec::::new()); - assert!(!state.found_matched); + assert!(state.found_matched); let chunk = DataChunk::from_pretty( "i f i F @@ -3306,7 +3310,7 @@ mod tests { &expect )); assert_eq!(state.first_output_row_id, Vec::::new()); - assert!(state.found_matched); + assert!(!state.found_matched); } #[tokio::test]