MCPcopy Create free account
hub / github.com/apache/datafusion / evaluate

Method evaluate

datafusion/functions-aggregate/src/average.rs:521–532  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

519 }
520
521 fn evaluate(&mut self) -> Result<ScalarValue> {
522 // In sliding-window mode `retract_batch` can bring `count` back to 0
523 // while `sum` remains `Some(..)` (possibly zero or a floating-point
524 // residual). Guard against that so the frame with no non-NULL values
525 // yields NULL rather than NaN / ±Inf.
526 let avg = if self.count == 0 {
527 None
528 } else {
529 self.sum.map(|f| f / self.count as f64)
530 };
531 Ok(ScalarValue::Float64(avg))
532 }
533
534 fn size(&self) -> usize {
535 size_of_val(self)

Callers

nothing calls this directly

Calls 15

newFunction · 0.85
avgMethod · 0.80
take_neededMethod · 0.80
null_countMethod · 0.80
with_data_typeMethod · 0.80
mapMethod · 0.45
buildMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45
into_iterMethod · 0.45
iterMethod · 0.45
append_valueMethod · 0.45

Tested by

no test coverage detected