Skip to content

Commit

Permalink
Add value type check in try_unary_dict (#2755)
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Sep 17, 2022
1 parent 46fcb0c commit 5e83ef9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arrow/src/compute/kernels/arity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ where
T: ArrowPrimitiveType,
F: Fn(T::Native) -> Result<T::Native>,
{
if array.value_type() != T::DATA_TYPE {
return Err(ArrowError::CastError(format!(
"Cannot perform the unary operation on dictionary array of value type {}",
array.value_type()
)));
}

let dict_values = array.values().as_any().downcast_ref().unwrap();
let values = try_unary::<T, F, T>(dict_values, op)?.into_data();
let data = array.data().clone().into_builder().child_data(vec![values]);
Expand Down

0 comments on commit 5e83ef9

Please sign in to comment.