gianm commented on a change in pull request #10340:
URL: https://github.com/apache/druid/pull/10340#discussion_r482515733



##########
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:
       Hmm, I wonder if this should be `NullHandling.defaultDoubleValue()`.
   
   Will this just happen if nothing gets read?

##########
File path: 
extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorCollector.java
##########
@@ -60,11 +60,11 @@ public static VarianceAggregatorCollector from(ByteBuffer 
buffer)
   }
 
   public static final Comparator<VarianceAggregatorCollector> COMPARATOR = 
(o1, o2) -> {
-    int compare = Longs.compare(o1.count, o2.count);
+    int compare = Doubles.compare(o1.nvariance, o2.nvariance);

Review comment:
       Will this sort the same way as `getVariance(isVariancePop)` in 
`finalizeComputation`?




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