JiajunBernoulli commented on code in PR #3202:
URL: https://github.com/apache/calcite/pull/3202#discussion_r1199575918


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -3809,6 +3809,29 @@ public static List distinct(List list) {
     return Collections.nCopies(numberOfElement, element);
   }
 
+  /** Support the ARRAY_EXCEPT function. */
+  public static List arrayExcept(List list1, List list2) {
+    final Set result = new LinkedHashSet<>(list1);
+    result.removeAll(list2);
+    return new ArrayList<>(result);
+  }
+
+  /** Support the ARRAY_INTERSECT function. */
+  public static List arrayIntersect(List list1, List list2) {
+    final Set result = new LinkedHashSet<>(list1);
+    result.retainAll(list2);
+    return new ArrayList<>(result);
+  }
+
+  /** Support the ARRAY_UNION function. */
+  public static List arrayUnion(List list1, List list2) {
+    final Set result =
+        new LinkedHashSet<>(Math.max((int) ((list1.size() + list2.size()) / 
.75f) + 1, 16));

Review Comment:
   Defining some variables will make it easier to understand.
   `Math.max((int) ((list1.size() + list2.size()) / .75f) + 1, 16)`.
    why `.75f`, why `16`?



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

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

Reply via email to