liuyongvs commented on code in PR #3263:
URL: https://github.com/apache/calcite/pull/3263#discussion_r1232895732


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -3883,6 +3883,59 @@ private static AtomicLong getAtomicLong(String key) {
     return atomic;
   }
 
+  /** Support the ARRAYS_OVERLAP function. */
+  public static @Nullable Boolean arraysOverlap(List list1, List list2) {
+    final List bigger = list1.size() > list2.size() ? list1 : list2;
+    final List smaller = list1.size() > list2.size() ? list2 : list1;
+    boolean hasNull = false;

Review Comment:
   hi @julianhyde @tanclary 
   1) why Util.intersects is fast, it has O(n * m) time space, and my 
implementation just has O(n+m) time space.
   ```
     public static <E> boolean intersects(Collection<E> c0, Collection<E> c1) {
       for (E e : c1) {
         if (c0.contains(e)) {
           return true;
         }
       }
       return false;
     }
   ```
   
   2)  about null
   Returns true if *array1 contains at least a non-null element present also in 
*array2*. If the arrays have no common element and they are both non-empty and 
either of them contains a null element null is returned, false otherwise
     
   if you look the three unit test, you will know why, and the implementation 
is align with spark
   ```
   f.checkScalar("arrays_overlap(array[1, null], array[1])", true,
           "BOOLEAN");
   f.checkNull("arrays_overlap(array[1], array[2, null])");
   f.checkScalar("arrays_overlap(array[1, 2], array[3])", false,
           "BOOLEAN NOT NULL");
   ```



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