Skip to content

Commit dcb4cd9

Browse files
committed
Refactor join type logic into utils.rs
Move the pure JoinType semantic rule to utils.rs, placing it alongside the existing join behavior helpers. Update HashJoinStream in stream.rs to focus solely on its stream-specific execution concern by removing unnecessary logic related to filtering.
1 parent 8e4c6eb commit dcb4cd9

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

datafusion/physical-plan/src/joins/hash_join/stream.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use crate::{
4242
BuildProbeJoinMetrics, ColumnIndex, JoinFilter, JoinHashMapType,
4343
StatefulStreamResult, adjust_indices_by_join_type, apply_join_filter_to_indices,
4444
build_batch_empty_build_side, build_batch_from_indices,
45-
need_produce_result_in_final,
45+
can_skip_probe_on_empty_build_side, need_produce_result_in_final,
4646
},
4747
};
4848

@@ -406,25 +406,13 @@ impl HashJoinStream {
406406
}
407407
}
408408

409-
/// Returns true when an empty build side fully determines the join result,
410-
/// so the probe side does not need to be consumed.
411-
fn can_skip_probe_on_empty_build_side(&self) -> bool {
412-
self.filter.is_none()
413-
&& matches!(
414-
self.join_type,
415-
JoinType::Inner
416-
| JoinType::Left
417-
| JoinType::LeftSemi
418-
| JoinType::LeftAnti
419-
| JoinType::LeftMark
420-
| JoinType::RightSemi
421-
)
422-
}
423-
424409
/// Returns the next state after the build side has been fully collected
425410
/// and any required build-side coordination has completed.
426411
fn next_state_after_build_ready(&self, left_data: &JoinLeftData) -> HashJoinStreamState {
427-
if left_data.map().is_empty() && self.can_skip_probe_on_empty_build_side() {
412+
if left_data.map().is_empty()
413+
&& self.filter.is_none()
414+
&& can_skip_probe_on_empty_build_side(self.join_type)
415+
{
428416
HashJoinStreamState::Completed
429417
} else {
430418
HashJoinStreamState::FetchProbeBatch

datafusion/physical-plan/src/joins/utils.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,20 @@ pub(crate) fn need_produce_result_in_final(join_type: JoinType) -> bool {
855855
)
856856
}
857857

858+
/// Returns true when an empty build side fully determines the join result,
859+
/// so the probe side does not need to be consumed.
860+
pub(crate) fn can_skip_probe_on_empty_build_side(join_type: JoinType) -> bool {
861+
matches!(
862+
join_type,
863+
JoinType::Inner
864+
| JoinType::Left
865+
| JoinType::LeftSemi
866+
| JoinType::LeftAnti
867+
| JoinType::LeftMark
868+
| JoinType::RightSemi
869+
)
870+
}
871+
858872
pub(crate) fn get_final_indices_from_shared_bitmap(
859873
shared_bitmap: &SharedBitmapBuilder,
860874
join_type: JoinType,

0 commit comments

Comments
 (0)