code: func (af *avgFunction) GetResult(evalCtx *AggEvaluateContext) (d types.Datum) {
  	switch evalCtx.Value.Kind() {
  	case types.KindFloat64:
  		sum := evalCtx.Value.GetFloat64()
  		d.SetFloat64(sum / float64(evalCtx.Count))
  		return
  	case types.KindMysqlDecimal:
  		x := evalCtx.Value.GetMysqlDecimal()
  		y := types.NewDecFromInt(evalCtx.Count)
  		to := new(types.MyDecimal)
  		err := types.DecimalDiv(x, y, to, types.DivFracIncr)
  		terror.Log(err)
  		frac := af.RetTp.Decimal
  		if frac == -1 {
  			frac = mysql.MaxDecimalScale
  		}
  		err = to.Round(to, mathutil.Min(frac, mysql.MaxDecimalScale), types.ModeHalfEven)
  		terror.Log(err)
  		d.SetMysqlDecimal(to)
  	}
  	return
  }
docs: // GetResult implements Aggregation interface.