code: func CastValue(ctx context.Context, val types.Datum, col *model.ColumnInfo) (casted types.Datum, err error) {
  	casted, err = val.ConvertTo(ctx.GetSessionVars().StmtCtx, &col.FieldType)
  	if err != nil {
  		if ctx.GetSessionVars().StrictSQLMode {
  			return casted, errors.Trace(err)
  		}
  		// TODO: add warnings.
  		log.Printf("cast value error %v", err)
  	}
  	return casted, nil
  }
docs: // CastValue casts a value based on column type.