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



##########
File path: arrow/src/compute/kernels/comparison.rs
##########
@@ -1104,27 +1104,71 @@ where
     T: TryInto<i128> + Copy + std::fmt::Debug,
 {
     match left.data_type() {
-        DataType::Dictionary(key_type, _) => {
-            return dyn_compare_scalar!(&left, right, key_type, eq_scalar);
+        DataType::Dictionary(key_type, value_type) => match 
value_type.as_ref() {
+            DataType::Int8
+            | DataType::Int16
+            | DataType::Int32
+            | DataType::Int64
+            | DataType::UInt8
+            | DataType::UInt16
+            | DataType::UInt32
+            | DataType::UInt64 => {dyn_compare_scalar!(&left, right, key_type, 
eq_scalar)}
+            _ => Err(ArrowError::ComputeError(
+                "Kernel only supports PrimitiveArray or DictionaryArray with 
Primitive values".to_string(),
+            ))
         }
-        _ => {
-            return dyn_compare_scalar!(&left, right, eq_scalar);
+        DataType::Int8
+        | DataType::Int16
+        | DataType::Int32
+        | DataType::Int64
+        | DataType::UInt8
+        | DataType::UInt16
+        | DataType::UInt32
+        | DataType::UInt64 => {
+            dyn_compare_scalar!(&left, right, eq_scalar)
         }
-    };
+        _ => Err(ArrowError::ComputeError(
+            "Kernel only supports PrimitiveArray or DictionaryArray with 
Primitive values".to_string(),
+        ))
+    }
 }
 
 /// Perform `left == right` operation on an array and a numeric scalar
 /// value. Supports StringArrays, and DictionaryArrays that have string values
 pub fn eq_dyn_utf8_scalar(left: Arc<dyn Array>, right: &str) -> 
Result<BooleanArray> {
-    match left.data_type() {
-        DataType::Dictionary(key_type, _) => {
-            return dyn_compare_utf8_scalar!(&left, right, key_type, 
eq_utf8_scalar);
-        }
-        _ => {
+    let result = match left.data_type() {
+        DataType::Dictionary(key_type, value_type) => match 
value_type.as_ref() {
+            DataType::Utf8 | DataType::LargeUtf8 => {
+                dyn_compare_utf8_scalar!(&left, right, key_type, 
eq_utf8_scalar)
+            }
+            _ => Err(ArrowError::ComputeError(
+                "Kernel only supports Utf8 or LargeUtf8 arrays or 
DictionaryArray with Utf8 or LargeUtf8 values".to_string(),
+            )),
+        },
+        DataType::Utf8 | DataType::LargeUtf8 => {
             let left = as_string_array(&left);
-            return eq_utf8_scalar(left, right);
+            eq_utf8_scalar(left, right)
         }
+        _ => Err(ArrowError::ComputeError(
+            "Kernel only supports Utf8 or LargeUtf8 arrays".to_string(),
+        )),
     };
+    result
+}
+
+/// Perform `left == right` operation on an array and a numeric scalar
+/// value. Supports BooleanArrays, and DictionaryArrays that have string values
+pub fn eq_dyn_bool_scalar(left: Arc<dyn Array>, right: bool) -> 
Result<BooleanArray> {
+    let result = match left.data_type() {
+        DataType::Boolean => {
+            let left = as_boolean_array(&left);
+            eq_bool_scalar(left, right)
+        }
+        _ => Err(ArrowError::ComputeError(
+            "Kernel only supports BooleanArray".to_string(),

Review comment:
       Yeah -- users can call `cast` if they want to convert their array into 
boolean first

##########
File path: arrow/src/compute/kernels/comparison.rs
##########
@@ -1104,27 +1104,71 @@ where
     T: TryInto<i128> + Copy + std::fmt::Debug,
 {
     match left.data_type() {
-        DataType::Dictionary(key_type, _) => {
-            return dyn_compare_scalar!(&left, right, key_type, eq_scalar);
+        DataType::Dictionary(key_type, value_type) => match 
value_type.as_ref() {
+            DataType::Int8
+            | DataType::Int16
+            | DataType::Int32
+            | DataType::Int64
+            | DataType::UInt8
+            | DataType::UInt16
+            | DataType::UInt32
+            | DataType::UInt64 => {dyn_compare_scalar!(&left, right, key_type, 
eq_scalar)}
+            _ => Err(ArrowError::ComputeError(
+                "Kernel only supports PrimitiveArray or DictionaryArray with 
Primitive values".to_string(),
+            ))
         }
-        _ => {
-            return dyn_compare_scalar!(&left, right, eq_scalar);
+        DataType::Int8
+        | DataType::Int16
+        | DataType::Int32
+        | DataType::Int64
+        | DataType::UInt8
+        | DataType::UInt16
+        | DataType::UInt32
+        | DataType::UInt64 => {
+            dyn_compare_scalar!(&left, right, eq_scalar)
         }
-    };
+        _ => Err(ArrowError::ComputeError(
+            "Kernel only supports PrimitiveArray or DictionaryArray with 
Primitive values".to_string(),
+        ))
+    }
 }
 
 /// Perform `left == right` operation on an array and a numeric scalar
 /// value. Supports StringArrays, and DictionaryArrays that have string values
 pub fn eq_dyn_utf8_scalar(left: Arc<dyn Array>, right: &str) -> 
Result<BooleanArray> {

Review comment:
       love it




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to