code: func (d *Datum) ToBool(sc *variable.StatementContext) (int64, error) {
  	isZero := false
  	switch d.Kind() {
  	case KindInt64:
  		isZero = (d.GetInt64() == 0)
  	case KindUint64:
  		isZero = (d.GetUint64() == 0)
  	case KindFloat32:
  		isZero = (RoundFloat(d.GetFloat64()) == 0)
  	case KindFloat64:
  		isZero = (RoundFloat(d.GetFloat64()) == 0)
  	case KindString, KindBytes:
  		iVal, err := StrToInt(sc, d.GetString())
  		if err != nil {
  			return iVal, errors.Trace(err)
  		}
  		isZero = iVal == 0
  	case KindMysqlTime:
  		isZero = d.GetMysqlTime().IsZero()
  	case KindMysqlDuration:
  		isZero = (d.GetMysqlDuration().Duration == 0)
  	case KindMysqlDecimal:
  		v, _ := d.GetMysqlDecimal().ToFloat64()
  		isZero = (RoundFloat(v) == 0)
  	case KindMysqlHex:
  		isZero = (d.GetMysqlHex().ToNumber() == 0)
  	case KindMysqlBit:
  		isZero = (d.GetMysqlBit().ToNumber() == 0)
  	case KindMysqlEnum:
  		isZero = (d.GetMysqlEnum().ToNumber() == 0)
  	case KindMysqlSet:
  		isZero = (d.GetMysqlSet().ToNumber() == 0)
  	default:
  		return 0, errors.Errorf("cannot convert %v(type %T) to bool", d.GetValue(), d.GetValue())
  	}
  	if isZero {
  		return 0, nil
  	}
  	return 1, nil
  }
docs: // ToBool converts to a bool.
  // We will use 1 for true, and 0 for false.