Skip to content

Commit ee7e33b

Browse files
kosiewadriangb
authored andcommitted
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 579dd30 commit ee7e33b

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
@@ -857,6 +857,20 @@ pub(crate) fn need_produce_result_in_final(join_type: JoinType) -> bool {
857857
)
858858
}
859859

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

0 commit comments

Comments
 (0)