Skip to content

Commit 698dcbb

Browse files
author
B Vadlamani
committed
support_partition_eval_mode
1 parent 4fa2df7 commit 698dcbb

1 file changed

Lines changed: 38 additions & 5 deletions

File tree

datafusion/physical-plan/src/joins/hash_join/partitioned_hash_eval.rs

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use std::{fmt::Display, hash::Hash, sync::Arc};
2121

2222
use arrow::{
23-
array::{ArrayRef, UInt64Array},
23+
array::{Array, ArrayRef, BooleanArray, Int32Array, UInt32Array, UInt64Array},
2424
datatypes::{DataType, Schema},
2525
record_batch::RecordBatch,
2626
};
@@ -335,10 +335,43 @@ impl PhysicalExpr for HashTableLookupExpr {
335335
let array = map.contain_keys(&join_keys)?;
336336
Ok(ColumnarValue::Array(Arc::new(array)))
337337
}
338-
Map::RoaringMap(_bimap) => {
339-
internal_err!(
340-
"Roaringbitmap is not support for partitioned hash evaluation"
341-
)
338+
Map::RoaringMap(bitmap) => {
339+
// For roaring bitmap, check membership directly
340+
// Roaring only supports u32 values, so we handle Int32 and UInt32 types
341+
if join_keys.len() != 1 {
342+
return internal_err!(
343+
"Roaring bitmap expects 1 join key, but got {}",
344+
join_keys.len()
345+
);
346+
}
347+
let key_col = &join_keys[0];
348+
let contains: BooleanArray = match key_col.data_type() {
349+
DataType::Int32 => {
350+
let arr = key_col
351+
.as_any()
352+
.downcast_ref::<Int32Array>()
353+
.expect("Expected Int32Array");
354+
arr.iter()
355+
.map(|v| v.map(|val| bitmap.contains(val as u32)))
356+
.collect()
357+
}
358+
DataType::UInt32 => {
359+
let arr = key_col
360+
.as_any()
361+
.downcast_ref::<UInt32Array>()
362+
.expect("Expected UInt32Array");
363+
arr.iter()
364+
.map(|v| v.map(|val| bitmap.contains(val)))
365+
.collect()
366+
}
367+
other => {
368+
return internal_err!(
369+
"Unsupported data type for roaring bitmap: {:?}",
370+
other
371+
);
372+
}
373+
};
374+
Ok(ColumnarValue::Array(Arc::new(contains)))
342375
}
343376
}
344377
}

0 commit comments

Comments
 (0)