alamb commented on code in PR #2826:
URL: https://github.com/apache/arrow-datafusion/pull/2826#discussion_r912346153


##########
datafusion/physical-expr/src/expressions/in_list.rs:
##########
@@ -230,39 +248,37 @@ macro_rules! set_contains_with_negated {
 fn in_list_primitive<T: ArrowPrimitiveType>(
     array: &PrimitiveArray<T>,
     values: &[<T as ArrowPrimitiveType>::Native],
-) -> Result<BooleanArray> {
-    compare_op_scalar!(
-        array,
-        values,
-        |x, v: &[<T as ArrowPrimitiveType>::Native]| v.contains(&x)
-    )
+) -> BooleanArray {
+    unary_cmp(array, |x| values.contains(&x))
 }
 
 // whether each value on the left (can be null) is contained in the non-null 
list
 fn not_in_list_primitive<T: ArrowPrimitiveType>(
     array: &PrimitiveArray<T>,
     values: &[<T as ArrowPrimitiveType>::Native],
-) -> Result<BooleanArray> {
-    compare_op_scalar!(
-        array,
-        values,
-        |x, v: &[<T as ArrowPrimitiveType>::Native]| !v.contains(&x)
-    )
+) -> BooleanArray {
+    unary_cmp(array, |x| !values.contains(&x))
 }
 
 // whether each value on the left (can be null) is contained in the non-null 
list
 fn in_list_utf8<OffsetSize: OffsetSizeTrait>(
     array: &GenericStringArray<OffsetSize>,
     values: &[&str],
-) -> Result<BooleanArray> {
-    compare_op_scalar!(array, values, |x, v: &[&str]| v.contains(&x))
+) -> BooleanArray {
+    array
+        .iter()
+        .map(|x| x.map(|x| !values.contains(&x)))

Review Comment:
   This change now does check each element if it is `Null` before invoking the 
closure where the `compare_op_scalar!` macro does not. However, given that that 
the closure will do some non trivial string checks, I think first checking for 
null will likely not slow it down



-- 
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