Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor : Improve hash join build side recordbatch size accuracy #13916

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion datafusion/physical-plan/src/joins/hash_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ use datafusion_physical_expr::equivalence::{
};
use datafusion_physical_expr::PhysicalExprRef;

use crate::spill::get_record_batch_memory_size;
use ahash::RandomState;
use datafusion_expr::Operator;
use datafusion_physical_expr_common::datum::compare_op_for_nested;
Expand Down Expand Up @@ -842,7 +843,7 @@ async fn collect_left_input(
let initial = (Vec::new(), 0, metrics, reservation);
let (batches, num_rows, metrics, mut reservation) = stream
.try_fold(initial, |mut acc, batch| async {
let batch_size = batch.get_array_memory_size();
let batch_size = get_record_batch_memory_size(&batch);
// Reserve memory for incoming batch
acc.3.try_grow(batch_size)?;
// Update metrics
Expand Down Expand Up @@ -3903,6 +3904,11 @@ mod tests {
err.to_string(),
"External error: Resources exhausted: Additional allocation failed with top memory consumers (across reservations) as: HashJoinInput"
);

assert_contains!(
err.to_string(),
"Failed to allocate additional 120 bytes for HashJoinInput"
Copy link
Contributor Author

@getChan getChan Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before fix. 408

);
}

Ok(())
Expand Down Expand Up @@ -3984,6 +3990,11 @@ mod tests {
"External error: Resources exhausted: Additional allocation failed with top memory consumers (across reservations) as: HashJoinInput[1]"

);

assert_contains!(
err.to_string(),
"Failed to allocate additional 120 bytes for HashJoinInput[1]"
);
}

Ok(())
Expand Down
Loading