kosiew commented on code in PR #21068:
URL: https://github.com/apache/datafusion/pull/21068#discussion_r3035219983


##########
datafusion/physical-plan/src/joins/utils.rs:
##########
@@ -1062,47 +1062,35 @@ pub(crate) fn build_batch_empty_build_side(
     column_indices: &[ColumnIndex],
     join_type: JoinType,
 ) -> Result<RecordBatch> {
-    match join_type {
-        // these join types only return data if the left side is not empty, so 
we return an
-        // empty RecordBatch
-        JoinType::Inner
-        | JoinType::Left
-        | JoinType::LeftSemi
-        | JoinType::RightSemi
-        | JoinType::LeftAnti
-        | JoinType::LeftMark => 
Ok(RecordBatch::new_empty(Arc::new(schema.clone()))),
+    if join_type.empty_build_side_produces_empty_result() {
+        // These join types only return data if the left side is not empty.
+        return Ok(RecordBatch::new_empty(Arc::new(schema.clone())));
+    }

Review Comment:
   @LiaCastaneda 
   I see your point - in the current hash-join control flow, that branch is 
effectively unreachable from the main runtime path because stream.rs moves 
empty-build + empty-result join types directly to Completed, and stream.rs now 
asserts that invariant.
   
   But `pub(crate) fn build_batch_empty_build_side` is a shared helper with its 
own contract, and this guard is relevant because:
   
   1. It keeps the helper semantically correct even if called from another path 
later.
   2. It is a safe fallback in release builds if the upstream invariant is ever 
accidentally violated.
   3. It makes the helper behavior explicit and self-contained, rather than 
relying entirely on one caller’s state machine.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to