expression: implement vectorized evaluation for builtinCastDecimalAsTimeSig (#12904)
This commit is contained in:
committed by
pingcap-github-bot
parent
c242d2bb5c
commit
1bbc313c66
@ -906,11 +906,45 @@ func (b *builtinCastDecimalAsRealSig) vecEvalReal(input *chunk.Chunk, result *ch
|
||||
}
|
||||
|
||||
func (b *builtinCastDecimalAsTimeSig) vectorized() bool {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *builtinCastDecimalAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk.Column) error {
|
||||
return errors.Errorf("not implemented")
|
||||
n := input.NumRows()
|
||||
buf, err := b.bufAllocator.get(types.ETDecimal, n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer b.bufAllocator.put(buf)
|
||||
if err := b.args[0].VecEvalDecimal(b.ctx, input, buf); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result.ResizeTime(n, false)
|
||||
result.MergeNulls(buf)
|
||||
times := result.Times()
|
||||
decimals := buf.Decimals()
|
||||
stmt := b.ctx.GetSessionVars().StmtCtx
|
||||
fsp := int8(b.tp.Decimal)
|
||||
for i := 0; i < n; i++ {
|
||||
if buf.IsNull(i) {
|
||||
continue
|
||||
}
|
||||
tm, err := types.ParseTimeFromFloatString(stmt, string(decimals[i].ToString()), 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 *builtinCastTimeAsIntSig) vectorized() bool {
|
||||
|
||||
@ -55,6 +55,7 @@ var vecBuiltinCastCases = map[string][]vecExprBenchCase{
|
||||
{retEvalType: types.ETJson, childrenTypes: []types.EvalType{types.ETJson}},
|
||||
{retEvalType: types.ETJson, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&jsonStringGener{}}},
|
||||
{retEvalType: types.ETJson, childrenTypes: []types.EvalType{types.ETDecimal}},
|
||||
{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETDecimal}},
|
||||
{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETInt}},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user