comphead commented on code in PR #11218:
URL: https://github.com/apache/datafusion/pull/11218#discussion_r1679586344
##########
datafusion/physical-plan/src/joins/sort_merge_join.rs:
##########
@@ -1503,12 +1579,39 @@ fn get_buffered_columns(
buffered_batch_idx: usize,
buffered_indices: &UInt64Array,
) -> Result<Vec<ArrayRef>, ArrowError> {
- buffered_data.batches[buffered_batch_idx]
- .batch
- .columns()
- .iter()
- .map(|column| take(column, &buffered_indices, None))
- .collect::<Result<Vec<_>, ArrowError>>()
+ get_buffered_columns_from_batch(
+ &buffered_data.batches[buffered_batch_idx],
+ buffered_indices,
+ )
+}
+
+#[inline(always)]
+fn get_buffered_columns_from_batch(
+ buffered_batch: &BufferedBatch,
+ buffered_indices: &UInt64Array,
+) -> Result<Vec<ArrayRef>, ArrowError> {
+ if let Some(spill_file) = &buffered_batch.spill_file {
+ // if spilled read from disk in smaller sub batches
+ let mut buffered_cols: Vec<ArrayRef> =
Vec::with_capacity(buffered_indices.len());
+
+ let file = BufReader::new(File::open(spill_file.path())?);
+ let reader = FileReader::try_new(file, None)?;
+
+ for batch in reader {
+ batch?.columns().iter().for_each(|column| {
+ buffered_cols.extend(take(column, &buffered_indices, None))
Review Comment:
It should be okay, as buffered indices are created by the same algorithm of
splitting incoming buffer batch by the batch size
(https://github.com/apache/datafusion/blob/main/datafusion/physical-plan/src/joins/sort_merge_join.rs#L1065)
the similar as we split buffered batch into subbatches during spilling by the
batch size. When it comes to read phase the data should be consistent.
But also to feel more confident I have added for spill tests more assertion
so now it also checks result between spilled and non spilled SMJ runs
--
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]