expression: implement vectorized evaluation for builtinCastDecimalAsDecimalSig (#13471)

This commit is contained in:
Catror
2019-11-19 11:31:23 +08:00
committed by pingcap-github-bot
parent 7f02792c5b
commit eeef19b4e7
2 changed files with 25 additions and 2 deletions

View File

@ -530,11 +530,33 @@ func (b *builtinCastRealAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk
}
func (b *builtinCastDecimalAsDecimalSig) vectorized() bool {
return false
return true
}
func (b *builtinCastDecimalAsDecimalSig) vecEvalDecimal(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
if err := b.args[0].VecEvalDecimal(b.ctx, input, result); err != nil {
return err
}
n := input.NumRows()
decs := result.Decimals()
sc := b.ctx.GetSessionVars().StmtCtx
conditionUnionAndUnsigned := b.inUnion && mysql.HasUnsignedFlag(b.tp.Flag)
for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
dec := &types.MyDecimal{}
if !(conditionUnionAndUnsigned && decs[i].IsNegative()) {
*dec = decs[i]
}
dec, err := types.ProduceDecWithSpecifiedTp(dec, b.tp, sc)
if err != nil {
return err
}
decs[i] = *dec
}
return nil
}
func (b *builtinCastDurationAsTimeSig) vectorized() bool {

View File

@ -81,6 +81,7 @@ var vecBuiltinCastCases = map[string][]vecExprBenchCase{
geners: []dataGenerator{
&jsonTimeGener{},
}},
{retEvalType: types.ETDecimal, childrenTypes: []types.EvalType{types.ETDecimal}},
},
}