nizarhejazi commented on code in PR #9086: URL: https://github.com/apache/pinot/pull/9086#discussion_r937064451
########## pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/SumPrecisionAggregationFunction.java: ########## @@ -126,10 +147,120 @@ public void aggregate(int length, AggregationResultHolder aggregationResultHolde aggregationResultHolder.setValue(sum); } + private void aggregateNullHandlingEnabled(int length, AggregationResultHolder aggregationResultHolder, + BlockValSet blockValSet, RoaringBitmap nullBitmap) { + BigDecimal sum = BigDecimal.ZERO; + switch (blockValSet.getValueType().getStoredType()) { + case INT: { + int[] intValues = blockValSet.getIntValuesSV(); + if (nullBitmap.getCardinality() < length) { + // TODO: need to update the for-loop terminating condition to: i < length & i < intValues.length? + for (int i = 0; i < length; i++) { + if (!nullBitmap.contains(i)) { + sum = sum.add(BigDecimal.valueOf(intValues[i])); + } + } + setAggregationResult(aggregationResultHolder, sum); + } + break; + } + case LONG: { + long[] longValues = blockValSet.getLongValuesSV(); + if (nullBitmap.getCardinality() < length) { + for (int i = 0; i < length; i++) { + if (!nullBitmap.contains(i)) { + sum = sum.add(BigDecimal.valueOf(longValues[i])); + } + } + setAggregationResult(aggregationResultHolder, sum); + } + break; + } + case FLOAT: { + float[] floatValues = blockValSet.getFloatValuesSV(); + if (nullBitmap.getCardinality() < length) { + for (int i = 0; i < length; i++) { + if (!nullBitmap.contains(i)) { + if (Float.isFinite(floatValues[i])) { + sum = sum.add(BigDecimal.valueOf(floatValues[i])); + } + } + } + setAggregationResult(aggregationResultHolder, sum); + } + break; + } + case DOUBLE: { + double[] doubleValues = blockValSet.getDoubleValuesSV(); + if (nullBitmap.getCardinality() < length) { + for (int i = 0; i < length; i++) { + if (!nullBitmap.contains(i)) { + // TODO(nhejazi): throw an exception here instead of ignoring infinite values? + if (Double.isFinite(doubleValues[i])) { Review Comment: fyi: this is gonna fail the whole SumPrecisionAgg function. So the previous behaviour is just throwing an exception and the operation failing. @Jackie-Jiang Do you wanna still remove this check? I -- 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...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org