code: func GetMaxValue(ft *types.FieldType) (max types.Datum) {
  	switch ft.Tp {
  	case mysql.TypeTiny, mysql.TypeShort, mysql.TypeInt24, mysql.TypeLong, mysql.TypeLonglong:
  		if mysql.HasUnsignedFlag(ft.Flag) {
  			max.SetUint64(types.IntergerUnsignedUpperBound(ft.Tp))
  		} else {
  			max.SetInt64(types.IntergerSignedUpperBound(ft.Tp))
  		}
  	case mysql.TypeFloat:
  		max.SetFloat32(float32(types.GetMaxFloat(ft.Flen, ft.Decimal)))
  	case mysql.TypeDouble:
  		max.SetFloat64(types.GetMaxFloat(ft.Flen, ft.Decimal))
  	case mysql.TypeString, mysql.TypeVarString, mysql.TypeVarchar, mysql.TypeBlob, mysql.TypeTinyBlob, mysql.TypeMediumBlob, mysql.TypeLongBlob:
  		val := types.MaxValueDatum()
  		bytes, err := codec.EncodeKey(nil, nil, val)
  		// should not happen
  		if err != nil {
  			logutil.Logger(context.Background()).Error("encode key fail", zap.Error(err))
  		}
  		max.SetBytes(bytes)
  	case mysql.TypeNewDecimal:
  		max.SetMysqlDecimal(types.NewMaxOrMinDec(false, ft.Flen, ft.Decimal))
  	case mysql.TypeDuration:
  		max.SetMysqlDuration(types.Duration{Duration: math.MaxInt64})
  	case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeTimestamp:
  		if ft.Tp == mysql.TypeDate || ft.Tp == mysql.TypeDatetime {
  			max.SetMysqlTime(types.Time{Time: types.MaxDatetime, Type: ft.Tp})
  		} else {
  			max.SetMysqlTime(types.MaxTimestamp)
  		}
  	}
  	return
  }
docs: // GetMaxValue returns the max value datum for each type.