github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/dbs/memristed/memex/builtin_time_vec_test.go (about)

     1  // Copyright 2020 WHTCORPS INC, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package memex
    15  
    16  import (
    17  	"math"
    18  	"math/rand"
    19  	"testing"
    20  
    21  	. "github.com/whtcorpsinc/check"
    22  	"github.com/whtcorpsinc/BerolinaSQL/ast"
    23  	"github.com/whtcorpsinc/BerolinaSQL/allegrosql"
    24  	"github.com/whtcorpsinc/milevadb/types"
    25  	"github.com/whtcorpsinc/milevadb/soliton/chunk"
    26  	"github.com/whtcorpsinc/milevadb/soliton/mock"
    27  )
    28  
    29  type periodGener struct {
    30  	randGen *defaultRandGen
    31  }
    32  
    33  func newPeriodGener() *periodGener {
    34  	return &periodGener{newDefaultRandGen()}
    35  }
    36  
    37  func (g *periodGener) gen() interface{} {
    38  	return int64((g.randGen.Intn(2500)+1)*100 + g.randGen.Intn(12) + 1)
    39  }
    40  
    41  // unitStrGener is used to generate strings which are unit format
    42  type unitStrGener struct {
    43  	randGen *defaultRandGen
    44  }
    45  
    46  func newUnitStrGener() *unitStrGener {
    47  	return &unitStrGener{newDefaultRandGen()}
    48  }
    49  
    50  func (g *unitStrGener) gen() interface{} {
    51  	units := []string{
    52  		"MICROSECOND",
    53  		"SECOND",
    54  		"MINUTE",
    55  		"HOUR",
    56  		"DAY",
    57  		"WEEK",
    58  		"MONTH",
    59  		"QUARTER",
    60  		"YEAR",
    61  	}
    62  
    63  	n := g.randGen.Intn(len(units))
    64  	return units[n]
    65  }
    66  
    67  type dateTimeUnitStrGener struct {
    68  	randGen *defaultRandGen
    69  }
    70  
    71  func newDateTimeUnitStrGener() *dateTimeUnitStrGener {
    72  	return &dateTimeUnitStrGener{newDefaultRandGen()}
    73  }
    74  
    75  // tzStrGener is used to generate strings which are timezones
    76  type tzStrGener struct{}
    77  
    78  func (g *tzStrGener) gen() interface{} {
    79  	tzs := []string{
    80  		"",
    81  		"GMT",
    82  		"MET",
    83  		"+00:00",
    84  		"+10:00",
    85  	}
    86  
    87  	n := rand.Int() % len(tzs)
    88  	return tzs[n]
    89  }
    90  
    91  func (g *dateTimeUnitStrGener) gen() interface{} {
    92  	dateTimes := []string{
    93  		"DAY",
    94  		"WEEK",
    95  		"MONTH",
    96  		"QUARTER",
    97  		"YEAR",
    98  		"DAY_MICROSECOND",
    99  		"DAY_SECOND",
   100  		"DAY_MINUTE",
   101  		"DAY_HOUR",
   102  		"YEAR_MONTH",
   103  	}
   104  
   105  	n := g.randGen.Intn(len(dateTimes))
   106  	return dateTimes[n]
   107  }
   108  
   109  var vecBuiltinTimeCases = map[string][]vecExprBenchCase{
   110  	ast.DateLiteral: {
   111  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETDatetime},
   112  			constants: []*Constant{{Value: types.NewStringCauset("2020-11-11"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   113  		},
   114  	},
   115  	ast.TimeLiteral: {
   116  		{retEvalType: types.ETDuration, childrenTypes: []types.EvalType{types.ETString},
   117  			constants: []*Constant{
   118  				{Value: types.NewStringCauset("838:59:59"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   119  		},
   120  	},
   121  	ast.DateDiff: {
   122  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime, types.ETDatetime}},
   123  	},
   124  	ast.DateFormat: {
   125  		{
   126  			retEvalType:   types.ETString,
   127  			childrenTypes: []types.EvalType{types.ETString, types.ETString},
   128  			geners:        []dataGenerator{&dateTimeStrGener{randGen: newDefaultRandGen()}, newTimeFormatGener(0.5)},
   129  		},
   130  	},
   131  	ast.Hour: {
   132  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDuration}, geners: []dataGenerator{newRangeDurationGener(0.2)}},
   133  	},
   134  	ast.Minute: {
   135  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDuration}, geners: []dataGenerator{newRangeDurationGener(0.2)}},
   136  	},
   137  	ast.Second: {
   138  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDuration}, geners: []dataGenerator{newRangeDurationGener(0.2)}},
   139  	},
   140  	ast.ToSeconds: {
   141  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   142  	},
   143  	ast.MicroSecond: {
   144  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDuration}, geners: []dataGenerator{newRangeDurationGener(0.2)}},
   145  	},
   146  	ast.Now: {
   147  		{retEvalType: types.ETDatetime},
   148  		{
   149  			retEvalType:   types.ETDatetime,
   150  			childrenTypes: []types.EvalType{types.ETInt},
   151  			geners:        []dataGenerator{newRangeInt64Gener(0, 7)},
   152  		},
   153  	},
   154  	ast.DayOfWeek: {
   155  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   156  	},
   157  	ast.DayOfYear: {
   158  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   159  	},
   160  	ast.Day: {},
   161  	ast.ToDays: {
   162  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   163  	},
   164  	ast.CurrentTime: {
   165  		{retEvalType: types.ETDuration},
   166  		{retEvalType: types.ETDuration, childrenTypes: []types.EvalType{types.ETInt}, geners: []dataGenerator{newRangeInt64Gener(0, 7)}}, // fsp must be in the range 0 to 6.
   167  	},
   168  	ast.Time: {
   169  		{retEvalType: types.ETDuration, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&dateTimeStrGener{randGen: newDefaultRandGen()}}},
   170  	},
   171  	ast.CurrentDate: {
   172  		{retEvalType: types.ETDatetime},
   173  	},
   174  	ast.MakeDate: {
   175  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETInt, types.ETInt},
   176  			geners: []dataGenerator{newRangeInt64Gener(0, 2200), newRangeInt64Gener(0, 365)},
   177  		},
   178  	},
   179  	ast.MakeTime: {
   180  		{retEvalType: types.ETDuration, childrenTypes: []types.EvalType{types.ETInt, types.ETInt, types.ETReal}, geners: []dataGenerator{newRangeInt64Gener(-1000, 1000)}},
   181  		{
   182  			retEvalType: types.ETDuration, childrenTypes: []types.EvalType{types.ETInt, types.ETInt, types.ETReal},
   183  			childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeLonglong, Flag: allegrosql.UnsignedFlag}},
   184  			geners:             []dataGenerator{newRangeInt64Gener(-1000, 1000)},
   185  		},
   186  		{retEvalType: types.ETDuration, childrenTypes: []types.EvalType{types.ETReal, types.ETReal, types.ETReal}, geners: []dataGenerator{newRangeRealGener(-1000.0, 1000.0, 0.1)}},
   187  	},
   188  	ast.PeriodAdd: {
   189  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}, geners: []dataGenerator{newPeriodGener(), newPeriodGener()}},
   190  	},
   191  	ast.PeriodDiff: {
   192  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}, geners: []dataGenerator{newPeriodGener(), newPeriodGener()}},
   193  	},
   194  	ast.Quarter: {
   195  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   196  	},
   197  	ast.TimeFormat: {
   198  		{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETDuration, types.ETString}, geners: []dataGenerator{newRangeDurationGener(0.5), newTimeFormatGener(0.5)}},
   199  	},
   200  	ast.TimeToSec: {
   201  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDuration}},
   202  	},
   203  	ast.SecToTime: {
   204  		{retEvalType: types.ETDuration, childrenTypes: []types.EvalType{types.ETReal}},
   205  	},
   206  	// This test case may fail due to the issue: https://github.com/whtcorpsinc/milevadb/issues/13638.
   207  	// We remove this case to stabilize CI, and will reopen this when we fix the issue above.
   208  	//ast.TimestampAdd: {
   209  	//	{
   210  	//		retEvalType:   types.ETString,
   211  	//		childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETDatetime},
   212  	//		geners:        []dataGenerator{&unitStrGener{newDefaultRandGen()}, nil, nil},
   213  	//	},
   214  	//},
   215  	ast.UnixTimestamp: {
   216  		{
   217  			retEvalType:   types.ETInt,
   218  			childrenTypes: []types.EvalType{types.ETDatetime},
   219  			childrenFieldTypes: []*types.FieldType{
   220  				{
   221  					Tp:      allegrosql.TypeDatetime,
   222  					Flen:    types.UnspecifiedLength,
   223  					Decimal: 0,
   224  					Flag:    allegrosql.BinaryFlag,
   225  				},
   226  			},
   227  			geners: []dataGenerator{&dateTimeGener{Fsp: 0, randGen: newDefaultRandGen()}},
   228  		},
   229  		{retEvalType: types.ETDecimal, childrenTypes: []types.EvalType{types.ETTimestamp}},
   230  		{retEvalType: types.ETInt},
   231  	},
   232  	ast.TimestamFIDeliff: {
   233  		{
   234  			retEvalType:   types.ETInt,
   235  			childrenTypes: []types.EvalType{types.ETString, types.ETDatetime, types.ETDatetime},
   236  			geners:        []dataGenerator{newUnitStrGener(), nil, nil}},
   237  	},
   238  	ast.TimestampLiteral: {
   239  		{retEvalType: types.ETTimestamp, childrenTypes: []types.EvalType{types.ETString},
   240  			constants: []*Constant{{Value: types.NewStringCauset("2020-12-04 00:00:00"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   241  		},
   242  	},
   243  	ast.SubDate: {},
   244  	ast.AddDate: {},
   245  	ast.SubTime: {
   246  		{
   247  			retEvalType:   types.ETString,
   248  			childrenTypes: []types.EvalType{types.ETString, types.ETString},
   249  			childrenFieldTypes: []*types.FieldType{nil, {
   250  				Tp:      allegrosql.TypeString,
   251  				Flen:    types.UnspecifiedLength,
   252  				Decimal: types.UnspecifiedLength,
   253  				Flag:    allegrosql.BinaryFlag,
   254  			}},
   255  			geners: []dataGenerator{
   256  				&dateStrGener{randGen: newDefaultRandGen()},
   257  				&dateStrGener{randGen: newDefaultRandGen()},
   258  			},
   259  		},
   260  		// builtinSubTimeStringNullSig
   261  		{
   262  			retEvalType:        types.ETString,
   263  			childrenTypes:      []types.EvalType{types.ETDatetime, types.ETDatetime},
   264  			childrenFieldTypes: []*types.FieldType{types.NewFieldType(allegrosql.TypeDate), types.NewFieldType(allegrosql.TypeDatetime)},
   265  		},
   266  	},
   267  	ast.AddTime: {
   268  		// builtinAddStringAndStringSig, a special case written by hand.
   269  		// arg1 has BinaryFlag here.
   270  		{
   271  			retEvalType:   types.ETString,
   272  			childrenTypes: []types.EvalType{types.ETString, types.ETString},
   273  			childrenFieldTypes: []*types.FieldType{nil, {
   274  				Tp:      allegrosql.TypeString,
   275  				Flen:    types.UnspecifiedLength,
   276  				Decimal: types.UnspecifiedLength,
   277  				Flag:    allegrosql.BinaryFlag,
   278  			}},
   279  			geners: []dataGenerator{
   280  				gener{*newDefaultGener(0.2, types.ETString)},
   281  				gener{*newDefaultGener(0.2, types.ETString)},
   282  			},
   283  		},
   284  	},
   285  	ast.Week: {
   286  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   287  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime, types.ETInt}},
   288  	},
   289  	ast.Month: {
   290  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   291  	},
   292  	ast.Year: {
   293  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   294  	},
   295  	ast.Date: {
   296  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETDatetime}},
   297  	},
   298  	ast.Timestamp: {
   299  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&dateTimeStrGener{randGen: newDefaultRandGen()}}},
   300  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&dateStrGener{randGen: newDefaultRandGen()}}},
   301  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&timeStrGener{randGen: newDefaultRandGen()}}},
   302  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETString}},
   303  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETString, types.ETString},
   304  			geners: []dataGenerator{&dateTimeStrGener{randGen: newDefaultRandGen()}, &timeStrGener{randGen: newDefaultRandGen()}}},
   305  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETString, types.ETString},
   306  			geners: []dataGenerator{&dateTimeStrGener{randGen: newDefaultRandGen()}, nil}},
   307  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETString, types.ETString},
   308  			geners: []dataGenerator{nil, &timeStrGener{randGen: newDefaultRandGen()}}},
   309  	},
   310  	ast.MonthName: {
   311  		{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETDatetime}},
   312  	},
   313  	ast.DayOfMonth: {
   314  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   315  	},
   316  	ast.DayName: {
   317  		{retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETDatetime}},
   318  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   319  		{retEvalType: types.ETReal, childrenTypes: []types.EvalType{types.ETDatetime}},
   320  	},
   321  	ast.UTCDate: {
   322  		{retEvalType: types.ETDatetime},
   323  	},
   324  	ast.UTCTimestamp: {
   325  		{retEvalType: types.ETTimestamp},
   326  		{retEvalType: types.ETTimestamp, childrenTypes: []types.EvalType{types.ETInt}, geners: []dataGenerator{newRangeInt64Gener(0, 7)}},
   327  	},
   328  	ast.UTCTime: {
   329  		{retEvalType: types.ETDuration},
   330  		{retEvalType: types.ETDuration, childrenTypes: []types.EvalType{types.ETInt}, geners: []dataGenerator{newRangeInt64Gener(0, 7)}},
   331  	},
   332  	ast.Weekday: {
   333  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   334  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}, geners: []dataGenerator{gener{*newDefaultGener(0.2, types.ETDatetime)}}},
   335  	},
   336  	ast.YearWeek: {
   337  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   338  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime, types.ETInt}},
   339  	},
   340  	ast.WeekOfYear: {
   341  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}},
   342  	},
   343  	ast.FromDays: {
   344  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETInt}},
   345  	},
   346  	ast.FromUnixTime: {
   347  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETDecimal},
   348  			geners: []dataGenerator{gener{*newDefaultGener(0.9, types.ETDecimal)}},
   349  		},
   350  	},
   351  	ast.StrToDate: {
   352  		{
   353  			retEvalType:   types.ETDatetime,
   354  			childrenTypes: []types.EvalType{types.ETString, types.ETString},
   355  			geners:        []dataGenerator{&dateStrGener{randGen: newDefaultRandGen()}, &constStrGener{"%y-%m-%d"}},
   356  		},
   357  		{
   358  			retEvalType:   types.ETDatetime,
   359  			childrenTypes: []types.EvalType{types.ETString, types.ETString},
   360  			geners:        []dataGenerator{&dateStrGener{NullRation: 0.3, randGen: newDefaultRandGen()}, nil},
   361  			constants:     []*Constant{nil, {Value: types.NewCauset("%Y-%m-%d"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   362  		},
   363  		{
   364  			retEvalType:   types.ETDatetime,
   365  			childrenTypes: []types.EvalType{types.ETString, types.ETString},
   366  			geners:        []dataGenerator{&dateStrGener{randGen: newDefaultRandGen()}, nil},
   367  			// "%y%m%d" is wrong format, STR_TO_DATE should be failed for all rows
   368  			constants: []*Constant{nil, {Value: types.NewCauset("%y%m%d"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   369  		},
   370  		{
   371  			retEvalType:   types.ETDuration,
   372  			childrenTypes: []types.EvalType{types.ETString, types.ETString},
   373  			geners:        []dataGenerator{&timeStrGener{nullRation: 0.3, randGen: newDefaultRandGen()}, nil},
   374  			constants:     []*Constant{nil, {Value: types.NewCauset("%H:%i:%s"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   375  		},
   376  		{
   377  			retEvalType:   types.ETDuration,
   378  			childrenTypes: []types.EvalType{types.ETString, types.ETString},
   379  			geners:        []dataGenerator{&timeStrGener{nullRation: 0.3, randGen: newDefaultRandGen()}, nil},
   380  			// "%H%i%s" is wrong format, STR_TO_DATE should be failed for all rows
   381  			constants: []*Constant{nil, {Value: types.NewCauset("%H%i%s"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   382  		},
   383  	},
   384  	ast.GetFormat: {
   385  		{
   386  			retEvalType:   types.ETString,
   387  			childrenTypes: []types.EvalType{types.ETString, types.ETString},
   388  			geners:        []dataGenerator{newFormatGener(0.2), newLocationGener(0.2)},
   389  		},
   390  	},
   391  	ast.Sysdate: {
   392  		// Because there is a chance that a time error will cause the test to fail,
   393  		// we cannot use the vectorized test framework to test builtinSysDateWithoutFspSig.
   394  		// We test the builtinSysDateWithoutFspSig in TestSysDate function.
   395  		// {retEvalType: types.ETDatetime},
   396  		// {retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETInt},
   397  		// 	geners: []dataGenerator{newRangeInt64Gener(0, 7)}},
   398  	},
   399  	ast.MilevaDBParseTso: {
   400  		{
   401  			retEvalType:   types.ETDatetime,
   402  			childrenTypes: []types.EvalType{types.ETInt},
   403  			geners:        []dataGenerator{newRangeInt64Gener(0, math.MaxInt64)},
   404  		},
   405  	},
   406  	ast.LastDay: {
   407  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETDatetime}},
   408  	},
   409  	ast.Extract: {
   410  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDatetime}, geners: []dataGenerator{newDateTimeUnitStrGener(), nil}},
   411  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration},
   412  			constants: []*Constant{{Value: types.NewStringCauset("MICROSECOND"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   413  		},
   414  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration},
   415  			constants: []*Constant{{Value: types.NewStringCauset("SECOND"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   416  		},
   417  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration},
   418  			constants: []*Constant{{Value: types.NewStringCauset("MINUTE"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   419  		},
   420  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration},
   421  			constants: []*Constant{{Value: types.NewStringCauset("HOUR"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   422  		},
   423  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration},
   424  			constants: []*Constant{{Value: types.NewStringCauset("SECOND_MICROSECOND"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   425  		},
   426  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration},
   427  			constants: []*Constant{{Value: types.NewStringCauset("MINUTE_MICROSECOND"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   428  		},
   429  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration},
   430  			constants: []*Constant{{Value: types.NewStringCauset("MINUTE_SECOND"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   431  		},
   432  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration},
   433  			constants: []*Constant{{Value: types.NewStringCauset("HOUR_MICROSECOND"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   434  		},
   435  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration},
   436  			constants: []*Constant{{Value: types.NewStringCauset("HOUR_SECOND"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   437  		},
   438  		{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETDuration},
   439  			constants: []*Constant{{Value: types.NewStringCauset("HOUR_MINUTE"), RetType: types.NewFieldType(allegrosql.TypeString)}},
   440  		},
   441  	},
   442  	ast.ConvertTz: {
   443  		{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETDatetime, types.ETString, types.ETString},
   444  			geners: []dataGenerator{nil, newNullWrappedGener(0.2, &tzStrGener{}), newNullWrappedGener(0.2, &tzStrGener{})}},
   445  	},
   446  }
   447  
   448  func (s *testVectorizeSuite2) TestVectorizedBuiltinTimeEvalOneVec(c *C) {
   449  	testVectorizedEvalOneVec(c, vecBuiltinTimeCases)
   450  }
   451  
   452  func (s *testVectorizeSuite2) TestVectorizedBuiltinTimeFunc(c *C) {
   453  	testVectorizedBuiltinFunc(c, vecBuiltinTimeCases)
   454  }
   455  
   456  func BenchmarkVectorizedBuiltinTimeEvalOneVec(b *testing.B) {
   457  	benchmarkVectorizedEvalOneVec(b, vecBuiltinTimeCases)
   458  }
   459  
   460  func BenchmarkVectorizedBuiltinTimeFunc(b *testing.B) {
   461  	benchmarkVectorizedBuiltinFunc(b, vecBuiltinTimeCases)
   462  }
   463  
   464  func (s *testEvaluatorSuite) TestVecMonth(c *C) {
   465  	ctx := mock.NewContext()
   466  	ctx.GetStochastikVars().ALLEGROSQLMode |= allegrosql.ModeNoZeroDate
   467  	ctx.GetStochastikVars().StmtCtx.TruncateAsWarning = true
   468  	input := chunk.New([]*types.FieldType{types.NewFieldType(allegrosql.TypeDatetime)}, 3, 3)
   469  	input.Reset()
   470  	input.AppendTime(0, types.ZeroDate)
   471  	input.AppendNull(0)
   472  	input.AppendTime(0, types.ZeroDate)
   473  
   474  	f, _, _, result := genVecBuiltinFuncBenchCase(ctx, ast.Month, vecExprBenchCase{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDatetime}})
   475  	c.Assert(ctx.GetStochastikVars().StrictALLEGROSQLMode, IsTrue)
   476  	c.Assert(f.vecEvalInt(input, result), IsNil)
   477  	c.Assert(len(ctx.GetStochastikVars().StmtCtx.GetWarnings()), Equals, 2)
   478  
   479  	ctx.GetStochastikVars().StmtCtx.InInsertStmt = true
   480  	ctx.GetStochastikVars().StmtCtx.TruncateAsWarning = false
   481  	c.Assert(f.vecEvalInt(input, result), NotNil)
   482  }