Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Added support for scalar comparison of dictionary.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Dec 16, 2021
1 parent 565cfae commit 9e58b49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/compute/comparison/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ macro_rules! compare_scalar {
let rhs = rhs.as_any().downcast_ref::<BinaryScalar<i64>>().unwrap();
binary::$op::<i64>(lhs, rhs.value().unwrap())
}
Dictionary(key_type) => {
match_integer_type!(key_type, |$T| {
let lhs = lhs.as_any().downcast_ref::<DictionaryArray<$T>>().unwrap();
let values = cmp_scalar(lhs.values(), rhs);

Box::new(DictionaryArray::<K>::from_data(
lhs.keys().clone(),
values.into(),
))
})
}
_ => todo!("Comparisons of {:?} are not yet supported", lhs.data_type()),
}
}};
Expand Down Expand Up @@ -337,6 +348,10 @@ pub fn can_gt_eq(data_type: &DataType) -> bool {

// The list of operations currently supported.
fn can_compare(data_type: &DataType) -> bool {
if let DataType::Dictionary(_, values) = data_type.to_logical_type() {
return can_compare(values.as_ref());
}

matches!(
data_type,
DataType::Boolean
Expand Down
1 change: 1 addition & 0 deletions tests/it/compute/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fn consistency() {
Duration(TimeUnit::Millisecond),
Duration(TimeUnit::Microsecond),
Duration(TimeUnit::Nanosecond),
Dictionary(IntegerType::Int32, Box::new(LargeBinary)),
];

// array <> array
Expand Down

0 comments on commit 9e58b49

Please sign in to comment.