huaxingao commented on code in PR #564:
URL: https://github.com/apache/datafusion-comet/pull/564#discussion_r1640539424


##########
core/src/execution/datafusion/expressions/covariance.rs:
##########
@@ -287,22 +296,24 @@ impl Accumulator for CovarianceAccumulator {
     }
 
     fn evaluate(&mut self) -> Result<ScalarValue> {
+        if self.count == 0.0 {
+            return Ok(ScalarValue::Float64(None));
+        }

Review Comment:
   The Spark implementation is:
   
   CovPopulation:
   ```
   
   if (n == 0.0) {
     return null
   } else {
     return ck/n
   }
   ```
   CovSample:
   ```
   if (n == 0.0) {
     return null
   } else if (n==1.0) {
     if (nullOnDivideByZero) {
       return null
     } else { 
       return NaN
     }
   } else {
     return ck/(n-1)
   }
   
   ```



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to