gortiz commented on code in PR #11822:
URL: https://github.com/apache/pinot/pull/11822#discussion_r1571898082


##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/array/BaseArrayAggIntFunction.java:
##########
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function.array;
+
+import it.unimi.dsi.fastutil.ints.AbstractIntCollection;
+import it.unimi.dsi.fastutil.ints.IntArrayList;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.roaringbitmap.RoaringBitmap;
+
+
+public abstract class BaseArrayAggIntFunction<I extends AbstractIntCollection>
+    extends BaseArrayAggFunction<I, IntArrayList> {
+  public BaseArrayAggIntFunction(ExpressionContext expression, 
FieldSpec.DataType dataType,
+      boolean nullHandlingEnabled) {
+    super(expression, dataType, nullHandlingEnabled);
+  }
+
+  abstract void setGroupByResult(GroupByResultHolder groupByResultHolder, int 
groupKey, int value);
+
+  @Override
+  protected void aggregateArrayGroupBySV(int length, int[] groupKeyArray,
+      GroupByResultHolder groupByResultHolder, BlockValSet blockValSet) {
+    int[] values = blockValSet.getIntValuesSV();
+    for (int i = 0; i < length; i++) {
+      setGroupByResult(groupByResultHolder, groupKeyArray[i], values[i]);
+    }
+  }
+
+  @Override
+  protected void aggregateArrayGroupBySVWithNull(int length, int[] 
groupKeyArray,
+      GroupByResultHolder groupByResultHolder, BlockValSet blockValSet, 
RoaringBitmap nullBitmap) {
+    int[] values = blockValSet.getIntValuesSV();
+    for (int i = 0; i < length; i++) {
+      if (!nullBitmap.contains(i)) {
+        setGroupByResult(groupByResultHolder, groupKeyArray[i], values[i]);
+      }
+    }

Review Comment:
   This doesn't seem to be postgres compatible. [Documentation 
says](https://www.postgresql.org/docs/current/functions-aggregate.html):
   
   > array_agg ( anynonarray ) → anyarray
   >    Collects all the input values, including nulls, into an array.
   
   And in fact that is how it behaves
   Example:
   ```
   postgres=# insert into A(a) values (1), (2), (3), (null), (5);
   INSERT 0 5
   postgres=# select array_agg(a) from A;
      array_agg    
   ----------------
    {1,2,3,NULL,5}
   (1 row)
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to