Jackie-Jiang commented on a change in pull request #6668:
URL: https://github.com/apache/incubator-pinot/pull/6668#discussion_r592619923



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/SumPrecisionAggregationFunction.java
##########
@@ -77,40 +85,142 @@ public GroupByResultHolder createGroupByResultHolder(int 
initialCapacity, int ma
   @Override
   public void aggregate(int length, AggregationResultHolder 
aggregationResultHolder,
       Map<ExpressionContext, BlockValSet> blockValSetMap) {
-    byte[][] valueArray = blockValSetMap.get(_expression).getBytesValuesSV();
-    BigDecimal sumValue = getDefaultResult(aggregationResultHolder);
-    for (int i = 0; i < length; i++) {
-      BigDecimal value = 
DataTypeConversionFunctions.bytesToBigDecimalObject(valueArray[i]);
-      sumValue = sumValue.add(value);
+    BigDecimal sum = getDefaultResult(aggregationResultHolder);
+    BlockValSet blockValSet = blockValSetMap.get(_expression);
+    switch (blockValSet.getValueType()) {
+      case INT:
+        int[] intValues = blockValSet.getIntValuesSV();
+        for (int i = 0; i < length; i++) {
+          sum = sum.add(BigDecimal.valueOf(intValues[i]));
+        }
+        break;
+      case LONG:
+        long[] longValues = blockValSet.getLongValuesSV();
+        for (int i = 0; i < length; i++) {
+          sum = sum.add(BigDecimal.valueOf(longValues[i]));
+        }
+        break;
+      case FLOAT:
+      case DOUBLE:

Review comment:
       We read them as string values. In order to construct `BigDecimal` from 
floating point values, we need to first convert the number into string format 




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

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