expression: implement vectorized evaluation for builtinCastStringAsTimeSig (#12947)
This commit is contained in:
committed by
pingcap-github-bot
parent
e4856f07fb
commit
3a074d4bf8
@ -1092,11 +1092,44 @@ func (b *builtinCastStringAsDecimalSig) vecEvalDecimal(input *chunk.Chunk, resul
|
||||
}
|
||||
|
||||
func (b *builtinCastStringAsTimeSig) vectorized() bool {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *builtinCastStringAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk.Column) error {
|
||||
return errors.Errorf("not implemented")
|
||||
n := input.NumRows()
|
||||
buf, err := b.bufAllocator.get(types.ETString, n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer b.bufAllocator.put(buf)
|
||||
if err := b.args[0].VecEvalString(b.ctx, input, buf); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result.ResizeTime(n, false)
|
||||
result.MergeNulls(buf)
|
||||
times := result.Times()
|
||||
stmtCtx := b.ctx.GetSessionVars().StmtCtx
|
||||
fsp := int8(b.tp.Decimal)
|
||||
for i := 0; i < n; i++ {
|
||||
if result.IsNull(i) {
|
||||
continue
|
||||
}
|
||||
tm, err := types.ParseTime(stmtCtx, buf.GetString(i), b.tp.Tp, fsp)
|
||||
if err != nil {
|
||||
if err = handleInvalidTimeError(b.ctx, err); err != nil {
|
||||
return err
|
||||
}
|
||||
result.SetNull(i, true)
|
||||
continue
|
||||
}
|
||||
times[i] = tm
|
||||
if b.tp.Tp == mysql.TypeDate {
|
||||
// Truncate hh:mm:ss part if the type is Date.
|
||||
times[i].Time = types.FromDate(tm.Time.Year(), tm.Time.Month(), tm.Time.Day(), 0, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *builtinCastDecimalAsIntSig) vectorized() bool {
|
||||
|
||||
@ -59,6 +59,12 @@ var vecBuiltinCastCases = map[string][]vecExprBenchCase{
|
||||
{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETReal}},
|
||||
{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETDecimal}},
|
||||
{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETInt}},
|
||||
{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETString},
|
||||
geners: []dataGenerator{
|
||||
&dataTimeStrGener{},
|
||||
&timeStrGener{},
|
||||
&dataStrGener{},
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user