comphead commented on code in PR #10892: URL: https://github.com/apache/datafusion/pull/10892#discussion_r1638432985
########## datafusion/physical-plan/src/joins/sort_merge_join.rs: ########## @@ -1422,6 +1449,38 @@ fn get_filter_column( filter_columns } +fn produce_buffered_null_batch( + schema: &SchemaRef, + streamed_schema: &SchemaRef, + buffered_indices: &PrimitiveArray<UInt64Type>, + buffered_batch: &BufferedBatch, +) -> Result<Option<RecordBatch>> { + if buffered_indices.is_empty() { + return Ok(None); + } + + // Take buffered (right) columns + let buffered_columns = buffered_batch + .batch + .columns() + .iter() + .map(|column| take(column, &buffered_indices, None)) + .collect::<Result<Vec<_>, ArrowError>>() + .map_err(Into::<DataFusionError>::into)?; + + // Create null streamed (left) columns + let mut streamed_columns = streamed_schema + .fields() + .iter() + .map(|f| new_null_array(f.data_type(), buffered_indices.len())) + .collect::<Vec<_>>(); + + streamed_columns.extend(buffered_columns); + let columns = streamed_columns; + + Ok(Some(RecordBatch::try_new(schema.clone(), columns)?)) Review Comment: Can we do just ``` Ok(Some(RecordBatch::try_new(schema.clone(), streamed_columns.extend(buffered_columns))?)) ``` -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org