code: func (sf *ScalarFunction) Eval(row chunk.Row) (d types.Datum, err error) {
  	var (
  		res    interface{}
  		isNull bool
  	)
  	switch tp, evalType := sf.GetType(), sf.GetType().EvalType(); evalType {
  	case types.ETInt:
  		var intRes int64
  		intRes, isNull, err = sf.EvalInt(sf.GetCtx(), row)
  		if mysql.HasUnsignedFlag(tp.Flag) {
  			res = uint64(intRes)
  		} else {
  			res = intRes
  		}
  	case types.ETReal:
  		res, isNull, err = sf.EvalReal(sf.GetCtx(), row)
  	case types.ETDecimal:
  		res, isNull, err = sf.EvalDecimal(sf.GetCtx(), row)
  	case types.ETDatetime, types.ETTimestamp:
  		res, isNull, err = sf.EvalTime(sf.GetCtx(), row)
  	case types.ETDuration:
  		res, isNull, err = sf.EvalDuration(sf.GetCtx(), row)
  	case types.ETJson:
  		res, isNull, err = sf.EvalJSON(sf.GetCtx(), row)
  	case types.ETString:
  		res, isNull, err = sf.EvalString(sf.GetCtx(), row)
  	}
  
  	if isNull || err != nil {
  		d.SetValue(nil)
  		return d, err
  	}
  	d.SetValue(res)
  	return
  }
docs: // Eval implements Expression interface.