code: func WrapWithCastAsDuration(ctx sessionctx.Context, expr Expression) Expression {
  	if expr.GetType().Tp == mysql.TypeDuration {
  		return expr
  	}
  	tp := types.NewFieldType(mysql.TypeDuration)
  	switch x := expr.GetType(); x.Tp {
  	case mysql.TypeDatetime, mysql.TypeTimestamp, mysql.TypeDate:
  		tp.Decimal = x.Decimal
  	default:
  		tp.Decimal = types.MaxFsp
  	}
  	tp.Flen = mysql.MaxDurationWidthNoFsp
  	if tp.Decimal > 0 {
  		tp.Flen = tp.Flen + 1 + tp.Decimal
  	}
  	return BuildCastFunction(ctx, expr, tp)
  }
docs: // WrapWithCastAsDuration wraps `expr` with `cast` if the return type of expr is
  // not type duration, otherwise, returns `expr` directly.