shenyu0127 commented on code in PR #11365:
URL: https://github.com/apache/pinot/pull/11365#discussion_r1299599246
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/VarianceAggregationFunction.java:
##########
@@ -116,8 +139,20 @@ protected void setGroupByResult(int groupKey,
GroupByResultHolder groupByResultH
public void aggregateGroupBySV(int length, int[] groupKeyArray,
GroupByResultHolder groupByResultHolder,
Map<ExpressionContext, BlockValSet> blockValSetMap) {
double[] values =
StatisticalAggregationFunctionUtils.getValSet(blockValSetMap, _expression);
- for (int i = 0; i < length; i++) {
- setGroupByResult(groupKeyArray[i], groupByResultHolder, 1L, values[i],
0.0);
+ RoaringBitmap nullBitmap = null;
+ if (_nullHandlingEnabled) {
+ nullBitmap = blockValSetMap.get(_expression).getNullBitmap();
+ }
+ if (nullBitmap != null && !nullBitmap.isEmpty()) {
+ for (int i = 0; i < length; i++) {
+ if (!nullBitmap.contains(i)) {
+ setGroupByResult(groupKeyArray[i], groupByResultHolder, 1L,
values[i], 0.0);
+ }
+ }
+ } else {
+ for (int i = 0; i < length; i++) {
+ setGroupByResult(groupKeyArray[i], groupByResultHolder, 1L, values[i],
0.0);
+ }
Review Comment:
Indeed. Done.
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/VarianceAggregationFunction.java:
##########
@@ -134,12 +169,7 @@ public void aggregateGroupByMV(int length, int[][]
groupKeysArray, GroupByResult
@Override
public VarianceTuple extractAggregationResult(AggregationResultHolder
aggregationResultHolder) {
- VarianceTuple varianceTuple = aggregationResultHolder.getResult();
- if (varianceTuple == null) {
- return new VarianceTuple(0L, 0.0, 0.0);
- } else {
- return varianceTuple;
- }
+ return aggregationResultHolder.getResult();
Review Comment:
We don't need to check if `_nullHandlingEnabled` is set here. This is
because we want to return NULL (not `-infi`) if `_nullHandlingEnabled` is false
and no matching row is found.
There was a bug in my previous commit: if `_nullHandlingEnabled` is false
and no matching row is found, it would not return NULL. I fixed it by modifying
other places.
--
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]