diff --git a/expression/builtin_time_vec.go b/expression/builtin_time_vec.go index b2f682e0c969b..410c1441367a5 100644 --- a/expression/builtin_time_vec.go +++ b/expression/builtin_time_vec.go @@ -1039,13 +1039,13 @@ func (b *builtinExtractDurationSig) vecEvalInt(input *chunk.Chunk, result *chunk i64s := result.Int64s() durIs := dur.GoDurations() var duration types.Duration + duration.Fsp = int8(b.args[1].GetType().Decimal) for i := 0; i < n; i++ { if result.IsNull(i) { continue } unitI := unit.GetString(i) duration.Duration = durIs[i] - duration.Fsp = int8(b.args[1].GetType().Decimal) i64s[i], err = types.ExtractDurationNum(&duration, unitI) if err != nil { return err diff --git a/expression/builtin_time_vec_test.go b/expression/builtin_time_vec_test.go index 190742b2684c5..63d64bde38a04 100644 --- a/expression/builtin_time_vec_test.go +++ b/expression/builtin_time_vec_test.go @@ -347,9 +347,36 @@ var vecBuiltinTimeCases = map[string][]vecExprBenchCase{ }, ast.Extract: { {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDatetime}, geners: []dataGenerator{&dateTimeUnitStrGener{}, nil}}, + {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration}, + constants: []*Constant{{Value: types.NewStringDatum("MICROSECOND"), RetType: types.NewFieldType(mysql.TypeString)}}, + }, {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration}, constants: []*Constant{{Value: types.NewStringDatum("SECOND"), RetType: types.NewFieldType(mysql.TypeString)}}, }, + {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration}, + constants: []*Constant{{Value: types.NewStringDatum("MINUTE"), RetType: types.NewFieldType(mysql.TypeString)}}, + }, + {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration}, + constants: []*Constant{{Value: types.NewStringDatum("HOUR"), RetType: types.NewFieldType(mysql.TypeString)}}, + }, + {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration}, + constants: []*Constant{{Value: types.NewStringDatum("SECOND_MICROSECOND"), RetType: types.NewFieldType(mysql.TypeString)}}, + }, + {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration}, + constants: []*Constant{{Value: types.NewStringDatum("MINUTE_MICROSECOND"), RetType: types.NewFieldType(mysql.TypeString)}}, + }, + {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration}, + constants: []*Constant{{Value: types.NewStringDatum("MINUTE_SECOND"), RetType: types.NewFieldType(mysql.TypeString)}}, + }, + {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration}, + constants: []*Constant{{Value: types.NewStringDatum("HOUR_MICROSECOND"), RetType: types.NewFieldType(mysql.TypeString)}}, + }, + {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration}, + constants: []*Constant{{Value: types.NewStringDatum("HOUR_SECOND"), RetType: types.NewFieldType(mysql.TypeString)}}, + }, + {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration}, + constants: []*Constant{{Value: types.NewStringDatum("HOUR_MINUTE"), RetType: types.NewFieldType(mysql.TypeString)}}, + }, }, }