expression: implement vectorized evaluation for 'builtinCastDurationAsStringSig' (#12541)
This commit is contained in:
@ -591,11 +591,44 @@ func (b *builtinCastDurationAsDurationSig) vecEvalDuration(input *chunk.Chunk, r
|
||||
}
|
||||
|
||||
func (b *builtinCastDurationAsStringSig) vectorized() bool {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *builtinCastDurationAsStringSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) error {
|
||||
return errors.Errorf("not implemented")
|
||||
n := input.NumRows()
|
||||
buf, err := b.bufAllocator.get(types.ETDuration, n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer b.bufAllocator.put(buf)
|
||||
if err := b.args[0].VecEvalDuration(b.ctx, input, buf); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var res string
|
||||
var isNull bool
|
||||
sc := b.ctx.GetSessionVars().StmtCtx
|
||||
result.ReserveString(n)
|
||||
for i := 0; i < n; i++ {
|
||||
if buf.IsNull(i) {
|
||||
result.AppendNull()
|
||||
continue
|
||||
}
|
||||
res, err = types.ProduceStrWithSpecifiedTp(buf.GetDuration(i, 0).String(), b.tp, sc, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, isNull, err = padZeroForBinaryType(res, b.tp, b.ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if isNull {
|
||||
result.AppendNull()
|
||||
continue
|
||||
}
|
||||
result.AppendString(res)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *builtinCastDecimalAsRealSig) vectorized() bool {
|
||||
|
||||
@ -37,6 +37,7 @@ var vecBuiltinCastCases = map[string][]vecExprBenchCase{
|
||||
},
|
||||
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETInt}},
|
||||
{retEvalType: types.ETDecimal, childrenTypes: []types.EvalType{types.ETDatetime}},
|
||||
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETDuration}},
|
||||
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETDatetime}},
|
||||
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETTimestamp}},
|
||||
{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETReal}},
|
||||
|
||||
Reference in New Issue
Block a user