Skip to content

Commit

Permalink
expression: implement vectorized evaluation for builtinSysDateWithout…
Browse files Browse the repository at this point in the history
…FspSig (#13348)
  • Loading branch information
ekalinin authored and ngaut committed Nov 11, 2019
1 parent c9c337e commit 838481a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 19 additions & 2 deletions expression/builtin_time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,28 @@ func (b *builtinFromUnixTime2ArgSig) vecEvalString(input *chunk.Chunk, result *c
}

func (b *builtinSysDateWithoutFspSig) vectorized() bool {
return false
return true
}

func (b *builtinSysDateWithoutFspSig) vecEvalTime(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
n := input.NumRows()
loc := b.ctx.GetSessionVars().Location()
nowTs, err := getStmtTimestamp(b.ctx)
if err != nil {
return err
}

now := nowTs.In(loc)
result.ResizeTime(n, false)
times := result.Times()
t, err := convertTimeToMysqlTime(now, 0, types.ModeHalfEven)
if err != nil {
return err
}
for i := 0; i < n; i++ {
times[i] = t
}
return nil
}

func (b *builtinExtractDatetimeSig) vectorized() bool {
Expand Down
3 changes: 3 additions & 0 deletions expression/builtin_time_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ var vecBuiltinTimeCases = map[string][]vecExprBenchCase{
geners: []dataGenerator{&formatGener{0.2}, &locationGener{0.2}},
},
},
ast.Sysdate: {
{retEvalType: types.ETDatetime},
},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinTimeEvalOneVec(c *C) {
Expand Down

0 comments on commit 838481a

Please sign in to comment.