suneet-s commented on a change in pull request #10340:
URL: https://github.com/apache/druid/pull/10340#discussion_r483063690



##########
File path: 
extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorFactory.java
##########
@@ -239,7 +240,9 @@ public Comparator getComparator()
   @Override
   public Object finalizeComputation(@Nullable Object object)
   {
-    return object == null ? null : ((VarianceAggregatorCollector) 
object).getVariance(isVariancePop);
+    return object == null || ((VarianceAggregatorCollector) object).count == 0
+           ? null

Review comment:
       I think so. I was able to hit this bug because of 
`VarianceSqlAggregatorTest#testVarianceOrderBy` One of the columns had no value 
for a row that was being grouped on.
   
   I then read this comment in `getVariance(...)` 
   
   ```
   // in SQL standard, we should return null for zero elements. But druid there 
should not be such a case
   ```
   which is why I returned null.
   
   I guess it could be nicer to return `NullHandling.defaultDoubleValue()` 
instead




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