code: func (d *Datum) ConvertTo(sc *stmtctx.StatementContext, target *FieldType) (Datum, error) {
  	if d.k == KindNull {
  		return Datum{}, nil
  	}
  	switch target.Tp { // TODO: implement mysql types convert when "CAST() AS" syntax are supported.
  	case mysql.TypeTiny, mysql.TypeShort, mysql.TypeInt24, mysql.TypeLong, mysql.TypeLonglong:
  		unsigned := mysql.HasUnsignedFlag(target.Flag)
  		if unsigned {
  			return d.convertToUint(sc, target)
  		}
  		return d.convertToInt(sc, target)
  	case mysql.TypeFloat, mysql.TypeDouble:
  		return d.convertToFloat(sc, target)
  	case mysql.TypeBlob, mysql.TypeTinyBlob, mysql.TypeMediumBlob, mysql.TypeLongBlob,
  		mysql.TypeString, mysql.TypeVarchar, mysql.TypeVarString:
  		return d.convertToString(sc, target)
  	case mysql.TypeTimestamp:
  		return d.convertToMysqlTimestamp(sc, target)
  	case mysql.TypeDatetime, mysql.TypeDate:
  		return d.convertToMysqlTime(sc, target)
  	case mysql.TypeDuration:
  		return d.convertToMysqlDuration(sc, target)
  	case mysql.TypeNewDecimal:
  		return d.convertToMysqlDecimal(sc, target)
  	case mysql.TypeYear:
  		return d.convertToMysqlYear(sc, target)
  	case mysql.TypeEnum:
  		return d.convertToMysqlEnum(sc, target)
  	case mysql.TypeBit:
  		return d.convertToMysqlBit(sc, target)
  	case mysql.TypeSet:
  		return d.convertToMysqlSet(sc, target)
  	case mysql.TypeJSON:
  		return d.convertToMysqlJSON(sc, target)
  	case mysql.TypeNull:
  		return Datum{}, nil
  	default:
  		panic("should never happen")
  	}
  }
docs: // ConvertTo converts a datum to the target field type.