You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "liuyongvs (via GitHub)" <gi...@apache.org> on 2023/06/14 10:09:49 UTC

[GitHub] [calcite] liuyongvs commented on a diff in pull request #3263: [CALCITE-5778] Add ARRAY_JOIN, ARRAYS_OVERLAP, ARRAYS_ZIP function (e…

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


##########
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;
+    if (smaller.size() > 0) {
+      final Set smallestSet = new HashSet();
+      for (Object element : smaller) {
+        if (element == null) {
+          hasNull = true;
+        } else {
+          smallestSet.add(element);
+        }
+      }
+      for (Object element : bigger) {
+        if (element == null) {
+          hasNull = true;
+        } else if (smallestSet.contains(element)) {
+          return true;
+        }
+      }
+    }
+    if (hasNull) {
+      return null;
+    } else {
+      return false;
+    }
+  }
+
+  /** Support the ARRAYS_ZIP function. */

Review Comment:
   comments:
   why need @SuppressWarnings("argument.type.incompatible")?
   it is following error in ci. the reason is List.add doc NullPointerException – if the specified element is null and this list does not permit null elements, and actually the ArrayList can add null.
   [Task :core:compileJava] [argument.type.incompatible] incompatible argument for parameter arg0 of add.
           row.add(value);



-- 
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: commits-unsubscribe@calcite.apache.org

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