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

Method evaluate

datafusion/spark/src/function/aggregate/avg.rs:190–200  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

188 }
189
190 fn evaluate(&mut self) -> Result<ScalarValue> {
191 if self.count == 0 {
192 // If all input are nulls, count will be 0 and we will get null after the division.
193 // This is consistent with Spark Average implementation.
194 Ok(ScalarValue::Float64(None))
195 } else {
196 Ok(ScalarValue::Float64(
197 self.sum.map(|f| f / self.count as f64),
198 ))
199 }
200 }
201
202 fn size(&self) -> usize {
203 size_of_val(self)

Calls 8

newFunction · 0.85
take_neededMethod · 0.80
mapMethod · 0.45
lenMethod · 0.45
into_iterMethod · 0.45
append_valueMethod · 0.45
append_nullMethod · 0.45
finishMethod · 0.45