jayzhan211 commented on code in PR #25427:
URL: https://github.com/apache/datafusion/pull/25427#discussion_r4046750965


##########
datafusion/functions-nested/src/array_has.rs:
##########
@@ -1683,4 +1690,79 @@ mod tests {
             vec![Some(true), Some(false)]
         );
     }
+
+    /// Invoke `array_has_any` with an array haystack and a scalar list of
+    /// `Int32` elements.
+    fn invoke_array_has_any_scalar(haystack: ArrayRef, scalar: Vec<i32>) -> 
ArrayRef {
+        let num_rows = haystack.len();
+        let haystack_type = haystack.data_type().clone();
+        let scalar = 
SingleRowListArrayBuilder::new(Arc::new(Int32Array::from(scalar)))
+            .build_list_scalar();
+        let scalar_type = scalar.data_type();
+        ArrayHasAny::new()
+            .invoke_with_args(ScalarFunctionArgs {
+                args: vec![
+                    ColumnarValue::Array(haystack),
+                    ColumnarValue::Scalar(scalar),
+                ],
+                arg_fields: vec![
+                    Arc::new(Field::new("haystack", haystack_type, true)),
+                    Arc::new(Field::new("scalar", scalar_type, true)),
+                ],
+                number_rows: num_rows,
+                return_field: Arc::new(Field::new("return", DataType::Boolean, 
true)),
+                config_options: Arc::new(ConfigOptions::default()),
+            })
+            .unwrap()
+            .into_array(num_rows)
+            .unwrap()
+    }
+
+    #[test]
+    fn test_array_has_any_scalar_sliced() {

Review Comment:
   Sliced test covers `List` + `FixedSizeList`; add `LargeList` for the third 
`ArrayWrapper` arm.
   
   ```rs
   let large = LargeListArray::from_iter_primitive::<Int32Type, _, _>(vec![
       Some(vec![Some(1), Some(2)]),
       Some(vec![Some(10), None, Some(30)]),
       Some(vec![Some(70)]),
   ]);
   let sliced: ArrayRef = Arc::new(large.slice(1, 1));
   let result = invoke_array_has_any_scalar(sliced, vec![1, 70, 30]);
   assert_eq!(
       result.as_boolean().iter().collect::<Vec<_>>(),
       vec![Some(true)]
   );
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to