diff --git a/runtime/vam/expr/agg/avg.go b/runtime/vam/expr/agg/avg.go index 173c53d293..b9e95b6e6b 100644 --- a/runtime/vam/expr/agg/avg.go +++ b/runtime/vam/expr/agg/avg.go @@ -14,11 +14,14 @@ type avg struct { var _ Func = (*avg)(nil) func (a *avg) Consume(vec vector.Any) { - if isNull(vec) { - return + var ncount uint32 + if nulls := vector.NullsOf(vec); nulls != nil { + ncount = nulls.TrueCount() + } + if ncount != vec.Len() { + a.count += uint64(vec.Len() - ncount) + a.sum = sum(a.sum, vec) } - a.count += uint64(vec.Len()) - a.sum = sum(a.sum, vec) } func (a *avg) Result(*super.Context) super.Value {