Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression:implement vectorized evaluation for builtinExtractDurationSig #13489

Merged
merged 15 commits into from
Dec 20, 2019
Merged
Prev Previous commit
Next Next commit
add test cases
  • Loading branch information
icditwang committed Dec 18, 2019
commit 31870f214e01072666421d21238767ebbf30d9a5
2 changes: 1 addition & 1 deletion expression/builtin_time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions expression/builtin_time_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)}},
},
},
}

Expand Down