westonpace commented on code in PR #15039:
URL: https://github.com/apache/datafusion/pull/15039#discussion_r1982443721


##########
datafusion/functions-nested/src/array_has.rs:
##########
@@ -439,6 +439,14 @@ fn array_has_all_and_any_dispatch<O: OffsetSizeTrait>(
 ) -> Result<ArrayRef> {
     let haystack = as_generic_list_array::<O>(haystack)?;
     let needle = as_generic_list_array::<O>(needle)?;
+    if needle.values().len() == 0 {
+        let result_value = match comparison_type {
+            ComparisonType::All => true,
+            ComparisonType::Any => false,
+        };
+        let result = BooleanArray::from(vec![result_value; haystack.len()]);

Review Comment:
   Using `BooleanBuffer::new_set` and `BooleanBuffer::new_unset` should be 
slightly more efficient.



##########
datafusion/functions-nested/src/array_has.rs:
##########
@@ -439,6 +439,14 @@ fn array_has_all_and_any_dispatch<O: OffsetSizeTrait>(
 ) -> Result<ArrayRef> {
     let haystack = as_generic_list_array::<O>(haystack)?;
     let needle = as_generic_list_array::<O>(needle)?;
+    if needle.values().len() == 0 {
+        let result_value = match comparison_type {
+            ComparisonType::All => true,
+            ComparisonType::Any => false,

Review Comment:
   It's weird to me that `All` is `true` and `Any` is `false` but I agree it 
matches the descriptions:
   
   `array_has_all: Returns true if all elements of sub-array exist in array.`
   `array_has_any: Returns true if any elements exist in both arrays.`
   
   I guess, from a set perspective, we have "true if the intersection of the 
two sets has the same length as needle" (all) and "true if the intersection of 
the two sets is non-empty" (any).
   



-- 
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...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to