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

[GitHub] [calcite] tanclary commented on a diff in pull request #3233: [CALCITE-5734] Add ARRAY_COMPACT function (enabled in Spark library)

tanclary commented on code in PR #3233:
URL: https://github.com/apache/calcite/pull/3233#discussion_r1210376844


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -3869,6 +3869,17 @@ private static AtomicLong getAtomicLong(String key) {
     return atomic;
   }
 
+  /** Support the ARRAY_COMPACT function. */
+  public static List removeNulls(List list) {
+    List result = new ArrayList();
+    for (int i = 0; i < list.size(); i++) {
+      if (list.get(i) != null) {
+        result.add(list.get(i));
+      }
+    }
+    return result;
+  }
+
   /** Support the ARRAY_DISTINCT function. */

Review Comment:
   Is there a reason to iterate by index rather than something like `for(Object obj : list)` ? Could help with readability a bit. Just an idea.



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