Skip to content

Commit 5e83ef9

Browse files
authored
Add value type check in try_unary_dict (#2755)
1 parent 46fcb0c commit 5e83ef9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arrow/src/compute/kernels/arity.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ where
156156
T: ArrowPrimitiveType,
157157
F: Fn(T::Native) -> Result<T::Native>,
158158
{
159+
if array.value_type() != T::DATA_TYPE {
160+
return Err(ArrowError::CastError(format!(
161+
"Cannot perform the unary operation on dictionary array of value type {}",
162+
array.value_type()
163+
)));
164+
}
165+
159166
let dict_values = array.values().as_any().downcast_ref().unwrap();
160167
let values = try_unary::<T, F, T>(dict_values, op)?.into_data();
161168
let data = array.data().clone().into_builder().child_data(vec![values]);

0 commit comments

Comments
 (0)