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 'builtinLastDaySig' #13592

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions expression/builtin_time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,11 +716,35 @@ func (b *builtinGetFormatSig) getFormat(format, location string) string {
}

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

func (b *builtinLastDaySig) vecEvalTime(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
n := input.NumRows()
buf, err := b.bufAllocator.get(types.ETDatetime, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf)
Comment on lines +724 to +728
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We can use result to get the son's result directly without alloc a buffer.
  2. We need to call b.arg[0].VecEvalTime to get son's result.

ds := buf.Times()
result.ResizeTime(n, false)
times := result.Times()
for i := 0; i < n; i++ {
tm := ds[i].Time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need check Null before calculate.

year, month, day := tm.Year(), tm.Month(), tm.Day()
if month == 0 || day == 0 {
return handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(buf.GetString(i)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the error can be handled, we should set null and continue.

}
lastDay := types.GetLastDay(year, month)
ret := types.Time{
Time: types.FromDate(year, month, lastDay, 0, 0, 0, 0),
Type: mysql.TypeDate,
Fsp: types.DefaultFsp,
}
times[i] = ret
}

return nil
}

func (b *builtinAddDateStringDecimalSig) vectorized() bool {
Expand Down