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


##########
datafusion/physical-plan/src/joins/sort_merge_join/stream.rs:
##########
@@ -1567,22 +1615,26 @@ impl SortMergeJoinStream {
     }
 }
 
-fn create_unmatched_columns(
-    join_type: JoinType,
-    schema: &SchemaRef,
-    size: usize,
-) -> Vec<ArrayRef> {
-    if matches!(join_type, JoinType::LeftMark | JoinType::RightMark) {
-        vec![Arc::new(BooleanArray::from(vec![false; size])) as ArrayRef]
+/// Materialize left (streamed) columns using slice or take.
+fn materialize_left_columns(
+    batch: &RecordBatch,
+    indices: &UInt64Array,
+) -> Result<Vec<ArrayRef>> {
+    if let Some(range) = is_contiguous_range(indices) {
+        Ok(batch.slice(range.start, range.len()).columns().to_vec())
     } else {
-        schema
-            .fields()
-            .iter()
-            .map(|f| new_null_array(f.data_type(), size))
-            .collect::<Vec<_>>()
+        Ok(take_arrays(batch.columns(), indices, None)?)
     }
 }
 
+fn create_unmatched_columns(schema: &SchemaRef, size: usize) -> Vec<ArrayRef> {

Review Comment:
   similar method used it other joins as well, in future we likely need to have 
a generic utility method to address this problem



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