|
20 | 20 | use std::{fmt::Display, hash::Hash, sync::Arc}; |
21 | 21 |
|
22 | 22 | use arrow::{ |
23 | | - array::{ArrayRef, UInt64Array}, |
| 23 | + array::{Array, ArrayRef, BooleanArray, Int32Array, UInt32Array, UInt64Array}, |
24 | 24 | datatypes::{DataType, Schema}, |
25 | 25 | record_batch::RecordBatch, |
26 | 26 | }; |
@@ -335,10 +335,43 @@ impl PhysicalExpr for HashTableLookupExpr { |
335 | 335 | let array = map.contain_keys(&join_keys)?; |
336 | 336 | Ok(ColumnarValue::Array(Arc::new(array))) |
337 | 337 | } |
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))) |
342 | 375 | } |
343 | 376 | } |
344 | 377 | } |
|
0 commit comments