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/05/20 08:01:06 UTC
[GitHub] [calcite] liuyongvs commented on a diff in pull request #3202: [CALCITE-5704] Add ARRAY_EXCEPT, ARRAY_INTERSECT, ARRAY_UNION function (enabled in Spark library)
liuyongvs commented on code in PR #3202:
URL: https://github.com/apache/calcite/pull/3202#discussion_r1199576905
##########
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:
refer to multisetUnionDistinct in SqlFunctions
--
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