pub fn into_arith(self, ctx: &mut EvalContext) -> Result<Datum> {
        match self {
            // MySQL will convert string to float for arithmetic operation
            Datum::Bytes(bs) => ConvertTo::<f64>::convert(&bs, ctx).map(From::from),
            Datum::Time(t) => {
                // if time has no precision, return int64
                let dec: Decimal = t.convert(ctx)?;
                if t.get_fsp() == 0 {
                    return Ok(Datum::I64(dec.as_i64().unwrap()));
                }
                Ok(Datum::Dec(dec))
            }
            Datum::Dur(d) => {
                let dec: Decimal = d.convert(ctx)?;
                if d.fsp() == 0 {
                    return Ok(Datum::I64(dec.as_i64().unwrap()));
                }
                Ok(Datum::Dec(dec))
            }
            a => Ok(a),
        }
    }
/// into_arith converts datum to appropriate datum for arithmetic computing.
/// Keep compatible with TiDB's `CoerceArithmetic` function.
into_arith converts datum to appropriate datum for arithmetic computing.
into_arith converts datum to appropriate datum for arithmetic computing .
pub fn into_arith(self, ctx: &mut EvalContext) -> Result<Datum> {
        match self {
            // MySQL will convert string to float for arithmetic operation
            Datum::Bytes(bs) => ConvertTo::<f64>::convert(&bs, ctx).map(From::from),
            Datum::Time(t) => {
                // if time has no precision, return int64
                let dec: Decimal = t.convert(ctx)?;
                if t.get_fsp() == 0 {
                    return Ok(Datum::I64(dec.as_i64().unwrap()));
                }
                Ok(Datum::Dec(dec))
            }
            Datum::Dur(d) => {
                let dec: Decimal = d.convert(ctx)?;
                if d.fsp() == 0 {
                    return Ok(Datum::I64(dec.as_i64().unwrap()));
                }
                Ok(Datum::Dec(dec))
            }
            a => Ok(a),
        }
    }
pub fn into_arith ( self , ctx : & mut EvalContext ) -> Result < Datum > { match self { // MySQL will convert string to float for arithmetic operation Datum :: Bytes ( bs ) => ConvertTo :: < f64 > :: convert ( & bs , ctx ) . map ( From :: from ) , Datum :: Time ( t ) => { // if time has no precision, return int64 let dec : Decimal = t . convert ( ctx ) ? ; if t . get_fsp ( ) == 0 { return Ok ( Datum :: I64 ( dec . as_i64 ( ) . unwrap ( ) ) ) ; } Ok ( Datum :: Dec ( dec ) ) } Datum :: Dur ( d ) => { let dec : Decimal = d . convert ( ctx ) ? ; if d . fsp ( ) == 0 { return Ok ( Datum :: I64 ( dec . as_i64 ( ) . unwrap ( ) ) ) ; } Ok ( Datum :: Dec ( dec ) ) } a => Ok ( a ) , } }
into_arith converts datum to appropriate datum for arithmetic computing.
into_arith converts datum to appropriate datum for arithmetic computing .
self
ctx
&mut EvalContext
self
ctx
&mut EvalContext