comphead commented on code in PR #21184:
URL: https://github.com/apache/datafusion/pull/21184#discussion_r3002301094


##########
datafusion/physical-plan/src/joins/semi_anti_mark_sort_merge_join/stream.rs:
##########
@@ -492,17 +507,37 @@ impl SemiAntiSortMergeJoinStream {
 
         // finish() converts the bit-packed builder directly to a
         // BooleanBuffer — no iteration or repacking needed.
-        let selection = BooleanArray::new(self.matched.finish(), None);
-
-        let selection = if self.is_semi {
-            selection
-        } else {
-            not(&selection)?
-        };
-
-        let filtered = filter_record_batch(batch, &selection)?;
-        if filtered.num_rows() > 0 {
-            self.coalescer.push_batch(filtered)?;
+        let matched_buf = self.matched.finish();
+
+        match self.join_type {
+            JoinType::LeftMark | JoinType::RightMark => {
+                // Mark joins emit ALL outer rows with a boolean match column 
appended.
+                debug_assert_eq!(
+                    self.schema.fields().len(),
+                    batch.num_columns() + 1,
+                    "Mark join output schema should be outer schema + 1 mark 
column"
+                );
+                let mark_col = Arc::new(BooleanArray::new(matched_buf, None)) 
as ArrayRef;
+                let mut columns = batch.columns().to_vec();
+                columns.push(mark_col);

Review Comment:
   ```suggestion
   let mut columns = Vec::with_capacity(batch.num_columns() + 1);
   columns.extend_from_slice(batch.columns());
   columns.push(mark_col);
   ```
   micro optimization, potentially avoiding extra allocations in `to_vec` on 
wide rows



-- 
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