expression: implement vectorized evaluation for builtinCurrentTime0ArgSig and builtinCurrentTime1ArgSig (#12837)
This commit is contained in:
@ -956,11 +956,27 @@ func (b *builtinSubDateDurationRealSig) vecEvalDuration(input *chunk.Chunk, resu
|
||||
}
|
||||
|
||||
func (b *builtinCurrentTime0ArgSig) vectorized() bool {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *builtinCurrentTime0ArgSig) vecEvalDuration(input *chunk.Chunk, result *chunk.Column) error {
|
||||
return errors.Errorf("not implemented")
|
||||
n := input.NumRows()
|
||||
nowTs, err := getStmtTimestamp(b.ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tz := b.ctx.GetSessionVars().Location()
|
||||
dur := nowTs.In(tz).Format(types.TimeFormat)
|
||||
res, err := types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, dur, types.MinFsp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result.ResizeGoDuration(n, false)
|
||||
durations := result.GoDurations()
|
||||
for i := 0; i < n; i++ {
|
||||
durations[i] = res.Duration
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *builtinTimeSig) vectorized() bool {
|
||||
@ -1098,11 +1114,38 @@ func (b *builtinDayOfWeekSig) vecEvalInt(input *chunk.Chunk, result *chunk.Colum
|
||||
}
|
||||
|
||||
func (b *builtinCurrentTime1ArgSig) vectorized() bool {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *builtinCurrentTime1ArgSig) vecEvalDuration(input *chunk.Chunk, result *chunk.Column) error {
|
||||
return errors.Errorf("not implemented")
|
||||
n := input.NumRows()
|
||||
buf, err := b.bufAllocator.get(types.ETInt, n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer b.bufAllocator.put(buf)
|
||||
if err := b.args[0].VecEvalInt(b.ctx, input, buf); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nowTs, err := getStmtTimestamp(b.ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tz := b.ctx.GetSessionVars().Location()
|
||||
dur := nowTs.In(tz).Format(types.TimeFSPFormat)
|
||||
stmtCtx := b.ctx.GetSessionVars().StmtCtx
|
||||
i64s := buf.Int64s()
|
||||
result.ResizeGoDuration(n, false)
|
||||
durations := result.GoDurations()
|
||||
for i := 0; i < n; i++ {
|
||||
res, err := types.ParseDuration(stmtCtx, dur, int8(i64s[i]))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
durations[i] = res.Duration
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *builtinUTCTimestampWithoutArgSig) vectorized() bool {
|
||||
|
||||
@ -39,7 +39,10 @@ var vecBuiltinTimeCases = map[string][]vecExprBenchCase{
|
||||
ast.DayOfWeek: {},
|
||||
ast.DayOfYear: {},
|
||||
ast.Day: {},
|
||||
ast.CurrentTime: {},
|
||||
ast.CurrentTime: {
|
||||
{retEvalType: types.ETDuration},
|
||||
{retEvalType: types.ETDuration, childrenTypes: []types.EvalType{types.ETInt}, geners: []dataGenerator{&rangeInt64Gener{0, 7}}}, // fsp must be in the range 0 to 6.
|
||||
},
|
||||
ast.CurrentDate: {
|
||||
{retEvalType: types.ETDatetime},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user