alamb commented on a change in pull request #1074:
URL: https://github.com/apache/arrow-rs/pull/1074#discussion_r773228604



##########
File path: arrow/src/compute/kernels/comparison.rs
##########
@@ -2522,4 +2603,19 @@ mod tests {
         regexp_is_match_utf8_scalar,
         vec![true, true, false, false]
     );
+    #[test]
+    fn test_eq_dyn_scalar_with_dict() {
+        let key_builder = PrimitiveBuilder::<UInt8Type>::new(3);
+        let value_builder = PrimitiveBuilder::<UInt8Type>::new(2);
+        let mut builder = PrimitiveDictionaryBuilder::new(key_builder, 
value_builder);
+        builder.append(123).unwrap();
+        builder.append_null().unwrap();
+        builder.append(223).unwrap();
+        let array = builder.finish();
+        let a_eq = eq_dyn_scalar(&array, 123).unwrap();

Review comment:
       looking good to me 👍 

##########
File path: arrow/src/compute/kernels/comparison.rs
##########
@@ -898,6 +898,87 @@ pub fn gt_eq_utf8_scalar<OffsetSize: 
StringOffsetSizeTrait>(
     compare_op_scalar!(left, right, |a, b| a >= b)
 }
 
+pub fn eq_dict_scalar<K, T>(left: &DictionaryArray<K>, right: T) -> 
Result<BooleanArray>
+where
+    K: ArrowNumericType,
+    T: IntoArrowNumericType,
+{
+    unpack_dict_comparison(left, eq_dyn_scalar(left.values().as_ref(), right)?)
+}
+/// Perform `left == right` operation on an array and a numeric scalar
+/// value. Supports PrimtiveArrays, and DictionaryArrays that have primitive 
values
+pub fn eq_dyn_scalar<T>(left: &dyn Array, right: T) -> Result<BooleanArray>
+where
+    T: IntoArrowNumericType,
+{
+    match left.data_type() {
+        DataType::UInt8 => {
+            let right: u8 = right.try_into().map_err(|_| {
+                ArrowError::ComputeError(format!(
+                    "Can not convert {:?} to u8 for comparison with 
UInt8Array",
+                    right
+                ))
+            })?;
+            eq_scalar::<UInt8Type>(as_primitive_array::<UInt8Type>(left), 
right)

Review comment:
       👍 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to