github.com/whtcorpsinc/milevadb-prod@v0.0.0-20211104133533-f57f4be3b597/dbs/memristed/memex/builtin_time_vec_generated.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  // Code generated by go generate in memex/generator; DO NOT EDIT.
    15  
    16  package memex
    17  
    18  import (
    19  	"github.com/whtcorpsinc/BerolinaSQL/allegrosql"
    20  	"github.com/whtcorpsinc/BerolinaSQL/terror"
    21  	"github.com/whtcorpsinc/milevadb/types"
    22  	"github.com/whtcorpsinc/milevadb/soliton/chunk"
    23  )
    24  
    25  func (b *builtinAddDatetimeAndDurationSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
    26  	n := input.NumEvents()
    27  
    28  	if err := b.args[0].VecEvalTime(b.ctx, input, result); err != nil {
    29  		return err
    30  	}
    31  	buf0 := result
    32  
    33  	buf1, err := b.bufSlabPredictor.get(types.ETDuration, n)
    34  	if err != nil {
    35  		return err
    36  	}
    37  	defer b.bufSlabPredictor.put(buf1)
    38  	if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
    39  		return err
    40  	}
    41  
    42  	result.MergeNulls(buf1)
    43  
    44  	arg0s := buf0.Times()
    45  
    46  	arg1s := buf1.GoDurations()
    47  
    48  	resultSlice := result.Times()
    49  
    50  	for i := 0; i < n; i++ {
    51  
    52  		if result.IsNull(i) {
    53  			continue
    54  		}
    55  
    56  		// get arg0 & arg1
    57  
    58  		arg0 := arg0s[i]
    59  
    60  		arg1 := arg1s[i]
    61  
    62  		// calculate
    63  
    64  		output, err := arg0.Add(b.ctx.GetStochastikVars().StmtCtx, types.Duration{Duration: arg1, Fsp: -1})
    65  
    66  		if err != nil {
    67  			return err
    68  		}
    69  
    70  		// commit result
    71  
    72  		resultSlice[i] = output
    73  
    74  	}
    75  	return nil
    76  }
    77  
    78  func (b *builtinAddDatetimeAndDurationSig) vectorized() bool {
    79  	return true
    80  }
    81  
    82  func (b *builtinAddDatetimeAndStringSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
    83  	n := input.NumEvents()
    84  
    85  	if err := b.args[0].VecEvalTime(b.ctx, input, result); err != nil {
    86  		return err
    87  	}
    88  	buf0 := result
    89  
    90  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
    91  	if err != nil {
    92  		return err
    93  	}
    94  	defer b.bufSlabPredictor.put(buf1)
    95  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
    96  		return err
    97  	}
    98  
    99  	result.MergeNulls(buf1)
   100  
   101  	arg0s := buf0.Times()
   102  
   103  	resultSlice := result.Times()
   104  
   105  	for i := 0; i < n; i++ {
   106  
   107  		if result.IsNull(i) {
   108  			continue
   109  		}
   110  
   111  		// get arg0 & arg1
   112  
   113  		arg0 := arg0s[i]
   114  
   115  		arg1 := buf1.GetString(i)
   116  
   117  		// calculate
   118  
   119  		if !isDuration(arg1) {
   120  			result.SetNull(i, true) // fixed: true
   121  			continue
   122  		}
   123  		sc := b.ctx.GetStochastikVars().StmtCtx
   124  		arg1Duration, err := types.ParseDuration(sc, arg1, types.GetFsp(arg1))
   125  		if err != nil {
   126  			if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
   127  				sc.AppendWarning(err)
   128  				result.SetNull(i, true) // fixed: true
   129  				continue
   130  			}
   131  			return err
   132  		}
   133  
   134  		output, err := arg0.Add(sc, arg1Duration)
   135  
   136  		if err != nil {
   137  			return err
   138  		}
   139  
   140  		// commit result
   141  
   142  		resultSlice[i] = output
   143  
   144  	}
   145  	return nil
   146  }
   147  
   148  func (b *builtinAddDatetimeAndStringSig) vectorized() bool {
   149  	return true
   150  }
   151  
   152  func (b *builtinAddDurationAndDurationSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   153  	n := input.NumEvents()
   154  
   155  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
   156  		return err
   157  	}
   158  	buf0 := result
   159  
   160  	buf1, err := b.bufSlabPredictor.get(types.ETDuration, n)
   161  	if err != nil {
   162  		return err
   163  	}
   164  	defer b.bufSlabPredictor.put(buf1)
   165  	if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
   166  		return err
   167  	}
   168  
   169  	result.MergeNulls(buf1)
   170  
   171  	arg0s := buf0.GoDurations()
   172  
   173  	arg1s := buf1.GoDurations()
   174  
   175  	resultSlice := result.GoDurations()
   176  
   177  	for i := 0; i < n; i++ {
   178  
   179  		if result.IsNull(i) {
   180  			continue
   181  		}
   182  
   183  		// get arg0 & arg1
   184  
   185  		arg0 := arg0s[i]
   186  
   187  		arg1 := arg1s[i]
   188  
   189  		// calculate
   190  
   191  		output, err := types.AddDuration(arg0, arg1)
   192  		if err != nil {
   193  			return err
   194  		}
   195  
   196  		// commit result
   197  
   198  		resultSlice[i] = output
   199  
   200  	}
   201  	return nil
   202  }
   203  
   204  func (b *builtinAddDurationAndDurationSig) vectorized() bool {
   205  	return true
   206  }
   207  
   208  func (b *builtinAddDurationAndStringSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   209  	n := input.NumEvents()
   210  
   211  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
   212  		return err
   213  	}
   214  	buf0 := result
   215  
   216  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
   217  	if err != nil {
   218  		return err
   219  	}
   220  	defer b.bufSlabPredictor.put(buf1)
   221  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
   222  		return err
   223  	}
   224  
   225  	result.MergeNulls(buf1)
   226  
   227  	arg0s := buf0.GoDurations()
   228  
   229  	resultSlice := result.GoDurations()
   230  
   231  	for i := 0; i < n; i++ {
   232  
   233  		if result.IsNull(i) {
   234  			continue
   235  		}
   236  
   237  		// get arg0 & arg1
   238  
   239  		arg0 := arg0s[i]
   240  
   241  		arg1 := buf1.GetString(i)
   242  
   243  		// calculate
   244  
   245  		if !isDuration(arg1) {
   246  			result.SetNull(i, true) // fixed: true
   247  			continue
   248  		}
   249  		sc := b.ctx.GetStochastikVars().StmtCtx
   250  		arg1Duration, err := types.ParseDuration(sc, arg1, types.GetFsp(arg1))
   251  		if err != nil {
   252  			if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
   253  				sc.AppendWarning(err)
   254  				result.SetNull(i, true) // fixed: true
   255  				continue
   256  			}
   257  			return err
   258  		}
   259  
   260  		output, err := types.AddDuration(arg0, arg1Duration.Duration)
   261  		if err != nil {
   262  			return err
   263  		}
   264  
   265  		// commit result
   266  
   267  		resultSlice[i] = output
   268  
   269  	}
   270  	return nil
   271  }
   272  
   273  func (b *builtinAddDurationAndStringSig) vectorized() bool {
   274  	return true
   275  }
   276  
   277  func (b *builtinAddStringAndDurationSig) vecEvalString(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   278  	n := input.NumEvents()
   279  
   280  	buf0, err := b.bufSlabPredictor.get(types.ETString, n)
   281  	if err != nil {
   282  		return err
   283  	}
   284  	defer b.bufSlabPredictor.put(buf0)
   285  	if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil {
   286  		return err
   287  	}
   288  
   289  	buf1, err := b.bufSlabPredictor.get(types.ETDuration, n)
   290  	if err != nil {
   291  		return err
   292  	}
   293  	defer b.bufSlabPredictor.put(buf1)
   294  	if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
   295  		return err
   296  	}
   297  
   298  	result.ReserveString(n)
   299  
   300  	arg1s := buf1.GoDurations()
   301  
   302  	for i := 0; i < n; i++ {
   303  
   304  		if buf0.IsNull(i) || buf1.IsNull(i) {
   305  			result.AppendNull()
   306  			continue
   307  		}
   308  
   309  		// get arg0 & arg1
   310  
   311  		arg0 := buf0.GetString(i)
   312  
   313  		arg1 := arg1s[i]
   314  
   315  		// calculate
   316  
   317  		sc := b.ctx.GetStochastikVars().StmtCtx
   318  		fsp1 := int8(b.args[1].GetType().Decimal)
   319  		arg1Duration := types.Duration{Duration: arg1, Fsp: fsp1}
   320  		var output string
   321  		if isDuration(arg0) {
   322  
   323  			output, err = strDurationAddDuration(sc, arg0, arg1Duration)
   324  
   325  			if err != nil {
   326  				if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
   327  					sc.AppendWarning(err)
   328  					result.AppendNull() // fixed: false
   329  					continue
   330  				}
   331  				return err
   332  			}
   333  		} else {
   334  
   335  			output, err = strDatetimeAddDuration(sc, arg0, arg1Duration)
   336  
   337  			if err != nil {
   338  				return err
   339  			}
   340  		}
   341  
   342  		// commit result
   343  
   344  		result.AppendString(output)
   345  
   346  	}
   347  	return nil
   348  }
   349  
   350  func (b *builtinAddStringAndDurationSig) vectorized() bool {
   351  	return true
   352  }
   353  
   354  func (b *builtinAddStringAndStringSig) vecEvalString(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   355  	n := input.NumEvents()
   356  
   357  	buf0, err := b.bufSlabPredictor.get(types.ETString, n)
   358  	if err != nil {
   359  		return err
   360  	}
   361  	defer b.bufSlabPredictor.put(buf0)
   362  	if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil {
   363  		return err
   364  	}
   365  
   366  	arg1Type := b.args[1].GetType()
   367  	if allegrosql.HasBinaryFlag(arg1Type.Flag) {
   368  		result.ReserveString(n)
   369  		for i := 0; i < n; i++ {
   370  			result.AppendNull()
   371  		}
   372  		return nil
   373  	}
   374  
   375  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
   376  	if err != nil {
   377  		return err
   378  	}
   379  	defer b.bufSlabPredictor.put(buf1)
   380  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
   381  		return err
   382  	}
   383  
   384  	result.ReserveString(n)
   385  
   386  	for i := 0; i < n; i++ {
   387  
   388  		if buf0.IsNull(i) || buf1.IsNull(i) {
   389  			result.AppendNull()
   390  			continue
   391  		}
   392  
   393  		// get arg0 & arg1
   394  
   395  		arg0 := buf0.GetString(i)
   396  
   397  		arg1 := buf1.GetString(i)
   398  
   399  		// calculate
   400  
   401  		sc := b.ctx.GetStochastikVars().StmtCtx
   402  		arg1Duration, err := types.ParseDuration(sc, arg1, getFsp4TimeAddSub(arg1))
   403  		if err != nil {
   404  			if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
   405  				sc.AppendWarning(err)
   406  				result.AppendNull() // fixed: false
   407  				continue
   408  			}
   409  			return err
   410  		}
   411  
   412  		var output string
   413  		if isDuration(arg0) {
   414  
   415  			output, err = strDurationAddDuration(sc, arg0, arg1Duration)
   416  
   417  			if err != nil {
   418  				if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
   419  					sc.AppendWarning(err)
   420  					result.AppendNull() // fixed: false
   421  					continue
   422  				}
   423  				return err
   424  			}
   425  		} else {
   426  
   427  			output, err = strDatetimeAddDuration(sc, arg0, arg1Duration)
   428  
   429  			if err != nil {
   430  				return err
   431  			}
   432  		}
   433  
   434  		// commit result
   435  
   436  		result.AppendString(output)
   437  
   438  	}
   439  	return nil
   440  }
   441  
   442  func (b *builtinAddStringAndStringSig) vectorized() bool {
   443  	return true
   444  }
   445  
   446  func (b *builtinAddDateAndDurationSig) vecEvalString(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   447  	n := input.NumEvents()
   448  
   449  	buf0, err := b.bufSlabPredictor.get(types.ETDuration, n)
   450  	if err != nil {
   451  		return err
   452  	}
   453  	defer b.bufSlabPredictor.put(buf0)
   454  	if err := b.args[0].VecEvalDuration(b.ctx, input, buf0); err != nil {
   455  		return err
   456  	}
   457  
   458  	buf1, err := b.bufSlabPredictor.get(types.ETDuration, n)
   459  	if err != nil {
   460  		return err
   461  	}
   462  	defer b.bufSlabPredictor.put(buf1)
   463  	if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
   464  		return err
   465  	}
   466  
   467  	result.ReserveString(n)
   468  
   469  	arg0s := buf0.GoDurations()
   470  
   471  	arg1s := buf1.GoDurations()
   472  
   473  	for i := 0; i < n; i++ {
   474  
   475  		if buf0.IsNull(i) || buf1.IsNull(i) {
   476  			result.AppendNull()
   477  			continue
   478  		}
   479  
   480  		// get arg0 & arg1
   481  
   482  		arg0 := arg0s[i]
   483  
   484  		arg1 := arg1s[i]
   485  
   486  		// calculate
   487  
   488  		fsp0 := int8(b.args[0].GetType().Decimal)
   489  		fsp1 := int8(b.args[1].GetType().Decimal)
   490  		arg1Duration := types.Duration{Duration: arg1, Fsp: fsp1}
   491  
   492  		sum, err := types.Duration{Duration: arg0, Fsp: fsp0}.Add(arg1Duration)
   493  
   494  		if err != nil {
   495  			return err
   496  		}
   497  		output := sum.String()
   498  
   499  		// commit result
   500  
   501  		result.AppendString(output)
   502  
   503  	}
   504  	return nil
   505  }
   506  
   507  func (b *builtinAddDateAndDurationSig) vectorized() bool {
   508  	return true
   509  }
   510  
   511  func (b *builtinAddDateAndStringSig) vecEvalString(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   512  	n := input.NumEvents()
   513  
   514  	buf0, err := b.bufSlabPredictor.get(types.ETDuration, n)
   515  	if err != nil {
   516  		return err
   517  	}
   518  	defer b.bufSlabPredictor.put(buf0)
   519  	if err := b.args[0].VecEvalDuration(b.ctx, input, buf0); err != nil {
   520  		return err
   521  	}
   522  
   523  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
   524  	if err != nil {
   525  		return err
   526  	}
   527  	defer b.bufSlabPredictor.put(buf1)
   528  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
   529  		return err
   530  	}
   531  
   532  	result.ReserveString(n)
   533  
   534  	arg0s := buf0.GoDurations()
   535  
   536  	for i := 0; i < n; i++ {
   537  
   538  		if buf0.IsNull(i) || buf1.IsNull(i) {
   539  			result.AppendNull()
   540  			continue
   541  		}
   542  
   543  		// get arg0 & arg1
   544  
   545  		arg0 := arg0s[i]
   546  
   547  		arg1 := buf1.GetString(i)
   548  
   549  		// calculate
   550  
   551  		if !isDuration(arg1) {
   552  			result.AppendNull() // fixed: false
   553  			continue
   554  		}
   555  		sc := b.ctx.GetStochastikVars().StmtCtx
   556  		arg1Duration, err := types.ParseDuration(sc, arg1, getFsp4TimeAddSub(arg1))
   557  		if err != nil {
   558  			if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
   559  				sc.AppendWarning(err)
   560  				result.AppendNull() // fixed: false
   561  				continue
   562  			}
   563  			return err
   564  		}
   565  
   566  		fsp0 := int8(b.args[0].GetType().Decimal)
   567  
   568  		sum, err := types.Duration{Duration: arg0, Fsp: fsp0}.Add(arg1Duration)
   569  
   570  		if err != nil {
   571  			return err
   572  		}
   573  		output := sum.String()
   574  
   575  		// commit result
   576  
   577  		result.AppendString(output)
   578  
   579  	}
   580  	return nil
   581  }
   582  
   583  func (b *builtinAddDateAndStringSig) vectorized() bool {
   584  	return true
   585  }
   586  
   587  func (b *builtinAddTimeDateTimeNullSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   588  	n := input.NumEvents()
   589  
   590  	result.ResizeTime(n, true)
   591  
   592  	return nil
   593  }
   594  
   595  func (b *builtinAddTimeDateTimeNullSig) vectorized() bool {
   596  	return true
   597  }
   598  
   599  func (b *builtinAddTimeStringNullSig) vecEvalString(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   600  	n := input.NumEvents()
   601  
   602  	result.ReserveString(n)
   603  	for i := 0; i < n; i++ {
   604  		result.AppendNull()
   605  	}
   606  
   607  	return nil
   608  }
   609  
   610  func (b *builtinAddTimeStringNullSig) vectorized() bool {
   611  	return true
   612  }
   613  
   614  func (b *builtinAddTimeDurationNullSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   615  	n := input.NumEvents()
   616  
   617  	result.ResizeGoDuration(n, true)
   618  
   619  	return nil
   620  }
   621  
   622  func (b *builtinAddTimeDurationNullSig) vectorized() bool {
   623  	return true
   624  }
   625  
   626  func (b *builtinSubDatetimeAndDurationSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   627  	n := input.NumEvents()
   628  
   629  	if err := b.args[0].VecEvalTime(b.ctx, input, result); err != nil {
   630  		return err
   631  	}
   632  	buf0 := result
   633  
   634  	buf1, err := b.bufSlabPredictor.get(types.ETDuration, n)
   635  	if err != nil {
   636  		return err
   637  	}
   638  	defer b.bufSlabPredictor.put(buf1)
   639  	if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
   640  		return err
   641  	}
   642  
   643  	result.MergeNulls(buf1)
   644  
   645  	arg0s := buf0.Times()
   646  
   647  	arg1s := buf1.GoDurations()
   648  
   649  	resultSlice := result.Times()
   650  
   651  	for i := 0; i < n; i++ {
   652  
   653  		if result.IsNull(i) {
   654  			continue
   655  		}
   656  
   657  		// get arg0 & arg1
   658  
   659  		arg0 := arg0s[i]
   660  
   661  		arg1 := arg1s[i]
   662  
   663  		// calculate
   664  
   665  		sc := b.ctx.GetStochastikVars().StmtCtx
   666  		arg1Duration := types.Duration{Duration: arg1, Fsp: -1}
   667  		arg1time, err := arg1Duration.ConvertToTime(sc, allegrosql.TypeDatetime)
   668  		if err != nil {
   669  			return err
   670  		}
   671  		tmFIDeluration := arg0.Sub(sc, &arg1time)
   672  		output, err := tmFIDeluration.ConvertToTime(sc, arg0.Type())
   673  
   674  		if err != nil {
   675  			return err
   676  		}
   677  
   678  		// commit result
   679  
   680  		resultSlice[i] = output
   681  
   682  	}
   683  	return nil
   684  }
   685  
   686  func (b *builtinSubDatetimeAndDurationSig) vectorized() bool {
   687  	return true
   688  }
   689  
   690  func (b *builtinSubDatetimeAndStringSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   691  	n := input.NumEvents()
   692  
   693  	if err := b.args[0].VecEvalTime(b.ctx, input, result); err != nil {
   694  		return err
   695  	}
   696  	buf0 := result
   697  
   698  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
   699  	if err != nil {
   700  		return err
   701  	}
   702  	defer b.bufSlabPredictor.put(buf1)
   703  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
   704  		return err
   705  	}
   706  
   707  	result.MergeNulls(buf1)
   708  
   709  	arg0s := buf0.Times()
   710  
   711  	resultSlice := result.Times()
   712  
   713  	for i := 0; i < n; i++ {
   714  
   715  		if result.IsNull(i) {
   716  			continue
   717  		}
   718  
   719  		// get arg0 & arg1
   720  
   721  		arg0 := arg0s[i]
   722  
   723  		arg1 := buf1.GetString(i)
   724  
   725  		// calculate
   726  
   727  		if !isDuration(arg1) {
   728  			result.SetNull(i, true) // fixed: true
   729  			continue
   730  		}
   731  		sc := b.ctx.GetStochastikVars().StmtCtx
   732  		arg1Duration, err := types.ParseDuration(sc, arg1, types.GetFsp(arg1))
   733  		if err != nil {
   734  			if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
   735  				sc.AppendWarning(err)
   736  				result.SetNull(i, true) // fixed: true
   737  				continue
   738  			}
   739  			return err
   740  		}
   741  		arg1time, err := arg1Duration.ConvertToTime(sc, allegrosql.TypeDatetime)
   742  		if err != nil {
   743  			return err
   744  		}
   745  		tmFIDeluration := arg0.Sub(sc, &arg1time)
   746  		output, err := tmFIDeluration.ConvertToTime(sc, allegrosql.TypeDatetime)
   747  
   748  		if err != nil {
   749  			return err
   750  		}
   751  
   752  		// commit result
   753  
   754  		resultSlice[i] = output
   755  
   756  	}
   757  	return nil
   758  }
   759  
   760  func (b *builtinSubDatetimeAndStringSig) vectorized() bool {
   761  	return true
   762  }
   763  
   764  func (b *builtinSubDurationAndDurationSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   765  	n := input.NumEvents()
   766  
   767  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
   768  		return err
   769  	}
   770  	buf0 := result
   771  
   772  	buf1, err := b.bufSlabPredictor.get(types.ETDuration, n)
   773  	if err != nil {
   774  		return err
   775  	}
   776  	defer b.bufSlabPredictor.put(buf1)
   777  	if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
   778  		return err
   779  	}
   780  
   781  	result.MergeNulls(buf1)
   782  
   783  	arg0s := buf0.GoDurations()
   784  
   785  	arg1s := buf1.GoDurations()
   786  
   787  	resultSlice := result.GoDurations()
   788  
   789  	for i := 0; i < n; i++ {
   790  
   791  		if result.IsNull(i) {
   792  			continue
   793  		}
   794  
   795  		// get arg0 & arg1
   796  
   797  		arg0 := arg0s[i]
   798  
   799  		arg1 := arg1s[i]
   800  
   801  		// calculate
   802  
   803  		output, err := types.SubDuration(arg0, arg1)
   804  		if err != nil {
   805  			return err
   806  		}
   807  
   808  		// commit result
   809  
   810  		resultSlice[i] = output
   811  
   812  	}
   813  	return nil
   814  }
   815  
   816  func (b *builtinSubDurationAndDurationSig) vectorized() bool {
   817  	return true
   818  }
   819  
   820  func (b *builtinSubDurationAndStringSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   821  	n := input.NumEvents()
   822  
   823  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
   824  		return err
   825  	}
   826  	buf0 := result
   827  
   828  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
   829  	if err != nil {
   830  		return err
   831  	}
   832  	defer b.bufSlabPredictor.put(buf1)
   833  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
   834  		return err
   835  	}
   836  
   837  	result.MergeNulls(buf1)
   838  
   839  	arg0s := buf0.GoDurations()
   840  
   841  	resultSlice := result.GoDurations()
   842  
   843  	for i := 0; i < n; i++ {
   844  
   845  		if result.IsNull(i) {
   846  			continue
   847  		}
   848  
   849  		// get arg0 & arg1
   850  
   851  		arg0 := arg0s[i]
   852  
   853  		arg1 := buf1.GetString(i)
   854  
   855  		// calculate
   856  
   857  		if !isDuration(arg1) {
   858  			result.SetNull(i, true) // fixed: true
   859  			continue
   860  		}
   861  		sc := b.ctx.GetStochastikVars().StmtCtx
   862  		arg1Duration, err := types.ParseDuration(sc, arg1, types.GetFsp(arg1))
   863  		if err != nil {
   864  			if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
   865  				sc.AppendWarning(err)
   866  				result.SetNull(i, true) // fixed: true
   867  				continue
   868  			}
   869  			return err
   870  		}
   871  
   872  		output, err := types.SubDuration(arg0, arg1Duration.Duration)
   873  		if err != nil {
   874  			return err
   875  		}
   876  
   877  		// commit result
   878  
   879  		resultSlice[i] = output
   880  
   881  	}
   882  	return nil
   883  }
   884  
   885  func (b *builtinSubDurationAndStringSig) vectorized() bool {
   886  	return true
   887  }
   888  
   889  func (b *builtinSubStringAndDurationSig) vecEvalString(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   890  	n := input.NumEvents()
   891  
   892  	buf0, err := b.bufSlabPredictor.get(types.ETString, n)
   893  	if err != nil {
   894  		return err
   895  	}
   896  	defer b.bufSlabPredictor.put(buf0)
   897  	if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil {
   898  		return err
   899  	}
   900  
   901  	buf1, err := b.bufSlabPredictor.get(types.ETDuration, n)
   902  	if err != nil {
   903  		return err
   904  	}
   905  	defer b.bufSlabPredictor.put(buf1)
   906  	if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
   907  		return err
   908  	}
   909  
   910  	result.ReserveString(n)
   911  
   912  	arg1s := buf1.GoDurations()
   913  
   914  	for i := 0; i < n; i++ {
   915  
   916  		if buf0.IsNull(i) || buf1.IsNull(i) {
   917  			result.AppendNull()
   918  			continue
   919  		}
   920  
   921  		// get arg0 & arg1
   922  
   923  		arg0 := buf0.GetString(i)
   924  
   925  		arg1 := arg1s[i]
   926  
   927  		// calculate
   928  
   929  		sc := b.ctx.GetStochastikVars().StmtCtx
   930  		fsp1 := int8(b.args[1].GetType().Decimal)
   931  		arg1Duration := types.Duration{Duration: arg1, Fsp: fsp1}
   932  		var output string
   933  		if isDuration(arg0) {
   934  
   935  			output, err = strDurationSubDuration(sc, arg0, arg1Duration)
   936  
   937  			if err != nil {
   938  				if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
   939  					sc.AppendWarning(err)
   940  					result.AppendNull() // fixed: false
   941  					continue
   942  				}
   943  				return err
   944  			}
   945  		} else {
   946  
   947  			output, err = strDatetimeSubDuration(sc, arg0, arg1Duration)
   948  
   949  			if err != nil {
   950  				return err
   951  			}
   952  		}
   953  
   954  		// commit result
   955  
   956  		result.AppendString(output)
   957  
   958  	}
   959  	return nil
   960  }
   961  
   962  func (b *builtinSubStringAndDurationSig) vectorized() bool {
   963  	return true
   964  }
   965  
   966  func (b *builtinSubStringAndStringSig) vecEvalString(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   967  	n := input.NumEvents()
   968  
   969  	buf0, err := b.bufSlabPredictor.get(types.ETString, n)
   970  	if err != nil {
   971  		return err
   972  	}
   973  	defer b.bufSlabPredictor.put(buf0)
   974  	if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil {
   975  		return err
   976  	}
   977  
   978  	arg1Type := b.args[1].GetType()
   979  	if allegrosql.HasBinaryFlag(arg1Type.Flag) {
   980  		result.ReserveString(n)
   981  		for i := 0; i < n; i++ {
   982  			result.AppendNull()
   983  		}
   984  		return nil
   985  	}
   986  
   987  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
   988  	if err != nil {
   989  		return err
   990  	}
   991  	defer b.bufSlabPredictor.put(buf1)
   992  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
   993  		return err
   994  	}
   995  
   996  	result.ReserveString(n)
   997  
   998  	for i := 0; i < n; i++ {
   999  
  1000  		if buf0.IsNull(i) || buf1.IsNull(i) {
  1001  			result.AppendNull()
  1002  			continue
  1003  		}
  1004  
  1005  		// get arg0 & arg1
  1006  
  1007  		arg0 := buf0.GetString(i)
  1008  
  1009  		arg1 := buf1.GetString(i)
  1010  
  1011  		// calculate
  1012  
  1013  		sc := b.ctx.GetStochastikVars().StmtCtx
  1014  		arg1Duration, err := types.ParseDuration(sc, arg1, getFsp4TimeAddSub(arg1))
  1015  		if err != nil {
  1016  			if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
  1017  				sc.AppendWarning(err)
  1018  				result.AppendNull() // fixed: false
  1019  				continue
  1020  			}
  1021  			return err
  1022  		}
  1023  
  1024  		var output string
  1025  		if isDuration(arg0) {
  1026  
  1027  			output, err = strDurationSubDuration(sc, arg0, arg1Duration)
  1028  
  1029  			if err != nil {
  1030  				if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
  1031  					sc.AppendWarning(err)
  1032  					result.AppendNull() // fixed: false
  1033  					continue
  1034  				}
  1035  				return err
  1036  			}
  1037  		} else {
  1038  
  1039  			output, err = strDatetimeSubDuration(sc, arg0, arg1Duration)
  1040  
  1041  			if err != nil {
  1042  				return err
  1043  			}
  1044  		}
  1045  
  1046  		// commit result
  1047  
  1048  		result.AppendString(output)
  1049  
  1050  	}
  1051  	return nil
  1052  }
  1053  
  1054  func (b *builtinSubStringAndStringSig) vectorized() bool {
  1055  	return true
  1056  }
  1057  
  1058  func (b *builtinSubDateAndDurationSig) vecEvalString(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1059  	n := input.NumEvents()
  1060  
  1061  	buf0, err := b.bufSlabPredictor.get(types.ETDuration, n)
  1062  	if err != nil {
  1063  		return err
  1064  	}
  1065  	defer b.bufSlabPredictor.put(buf0)
  1066  	if err := b.args[0].VecEvalDuration(b.ctx, input, buf0); err != nil {
  1067  		return err
  1068  	}
  1069  
  1070  	buf1, err := b.bufSlabPredictor.get(types.ETDuration, n)
  1071  	if err != nil {
  1072  		return err
  1073  	}
  1074  	defer b.bufSlabPredictor.put(buf1)
  1075  	if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
  1076  		return err
  1077  	}
  1078  
  1079  	result.ReserveString(n)
  1080  
  1081  	arg0s := buf0.GoDurations()
  1082  
  1083  	arg1s := buf1.GoDurations()
  1084  
  1085  	for i := 0; i < n; i++ {
  1086  
  1087  		if buf0.IsNull(i) || buf1.IsNull(i) {
  1088  			result.AppendNull()
  1089  			continue
  1090  		}
  1091  
  1092  		// get arg0 & arg1
  1093  
  1094  		arg0 := arg0s[i]
  1095  
  1096  		arg1 := arg1s[i]
  1097  
  1098  		// calculate
  1099  
  1100  		fsp0 := int8(b.args[0].GetType().Decimal)
  1101  		fsp1 := int8(b.args[1].GetType().Decimal)
  1102  		arg1Duration := types.Duration{Duration: arg1, Fsp: fsp1}
  1103  
  1104  		sum, err := types.Duration{Duration: arg0, Fsp: fsp0}.Sub(arg1Duration)
  1105  
  1106  		if err != nil {
  1107  			return err
  1108  		}
  1109  		output := sum.String()
  1110  
  1111  		// commit result
  1112  
  1113  		result.AppendString(output)
  1114  
  1115  	}
  1116  	return nil
  1117  }
  1118  
  1119  func (b *builtinSubDateAndDurationSig) vectorized() bool {
  1120  	return true
  1121  }
  1122  
  1123  func (b *builtinSubDateAndStringSig) vecEvalString(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1124  	n := input.NumEvents()
  1125  
  1126  	buf0, err := b.bufSlabPredictor.get(types.ETDuration, n)
  1127  	if err != nil {
  1128  		return err
  1129  	}
  1130  	defer b.bufSlabPredictor.put(buf0)
  1131  	if err := b.args[0].VecEvalDuration(b.ctx, input, buf0); err != nil {
  1132  		return err
  1133  	}
  1134  
  1135  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
  1136  	if err != nil {
  1137  		return err
  1138  	}
  1139  	defer b.bufSlabPredictor.put(buf1)
  1140  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
  1141  		return err
  1142  	}
  1143  
  1144  	result.ReserveString(n)
  1145  
  1146  	arg0s := buf0.GoDurations()
  1147  
  1148  	for i := 0; i < n; i++ {
  1149  
  1150  		if buf0.IsNull(i) || buf1.IsNull(i) {
  1151  			result.AppendNull()
  1152  			continue
  1153  		}
  1154  
  1155  		// get arg0 & arg1
  1156  
  1157  		arg0 := arg0s[i]
  1158  
  1159  		arg1 := buf1.GetString(i)
  1160  
  1161  		// calculate
  1162  
  1163  		if !isDuration(arg1) {
  1164  			result.AppendNull() // fixed: false
  1165  			continue
  1166  		}
  1167  		sc := b.ctx.GetStochastikVars().StmtCtx
  1168  		arg1Duration, err := types.ParseDuration(sc, arg1, getFsp4TimeAddSub(arg1))
  1169  		if err != nil {
  1170  			if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
  1171  				sc.AppendWarning(err)
  1172  				result.AppendNull() // fixed: false
  1173  				continue
  1174  			}
  1175  			return err
  1176  		}
  1177  
  1178  		fsp0 := int8(b.args[0].GetType().Decimal)
  1179  
  1180  		sum, err := types.Duration{Duration: arg0, Fsp: fsp0}.Sub(arg1Duration)
  1181  
  1182  		if err != nil {
  1183  			return err
  1184  		}
  1185  		output := sum.String()
  1186  
  1187  		// commit result
  1188  
  1189  		result.AppendString(output)
  1190  
  1191  	}
  1192  	return nil
  1193  }
  1194  
  1195  func (b *builtinSubDateAndStringSig) vectorized() bool {
  1196  	return true
  1197  }
  1198  
  1199  func (b *builtinSubTimeDateTimeNullSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1200  	n := input.NumEvents()
  1201  
  1202  	result.ResizeTime(n, true)
  1203  
  1204  	return nil
  1205  }
  1206  
  1207  func (b *builtinSubTimeDateTimeNullSig) vectorized() bool {
  1208  	return true
  1209  }
  1210  
  1211  func (b *builtinSubTimeStringNullSig) vecEvalString(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1212  	n := input.NumEvents()
  1213  
  1214  	result.ReserveString(n)
  1215  	for i := 0; i < n; i++ {
  1216  		result.AppendNull()
  1217  	}
  1218  
  1219  	return nil
  1220  }
  1221  
  1222  func (b *builtinSubTimeStringNullSig) vectorized() bool {
  1223  	return true
  1224  }
  1225  
  1226  func (b *builtinSubTimeDurationNullSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1227  	n := input.NumEvents()
  1228  
  1229  	result.ResizeGoDuration(n, true)
  1230  
  1231  	return nil
  1232  }
  1233  
  1234  func (b *builtinSubTimeDurationNullSig) vectorized() bool {
  1235  	return true
  1236  }
  1237  
  1238  func (b *builtinNullTimeDiffSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1239  	n := input.NumEvents()
  1240  	result.ResizeGoDuration(n, true)
  1241  	return nil
  1242  }
  1243  
  1244  func (b *builtinNullTimeDiffSig) vectorized() bool {
  1245  	return true
  1246  }
  1247  
  1248  func (b *builtinTimeStringTimeDiffSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1249  	n := input.NumEvents()
  1250  	result.ResizeGoDuration(n, false)
  1251  	r64s := result.GoDurations()
  1252  	buf0, err := b.bufSlabPredictor.get(types.ETDatetime, n)
  1253  	if err != nil {
  1254  		return err
  1255  	}
  1256  	defer b.bufSlabPredictor.put(buf0)
  1257  
  1258  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
  1259  	if err != nil {
  1260  		return err
  1261  	}
  1262  	defer b.bufSlabPredictor.put(buf1)
  1263  
  1264  	if err := b.args[0].VecEvalTime(b.ctx, input, buf0); err != nil {
  1265  		return err
  1266  	}
  1267  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
  1268  		return err
  1269  	}
  1270  
  1271  	result.MergeNulls(buf0, buf1)
  1272  	arg0 := buf0.Times()
  1273  	stmtCtx := b.ctx.GetStochastikVars().StmtCtx
  1274  	for i := 0; i < n; i++ {
  1275  		if result.IsNull(i) {
  1276  			continue
  1277  		}
  1278  		lhsTime := arg0[i]
  1279  		_, rhsTime, rhsIsDuration, err := convertStringToDuration(stmtCtx, buf1.GetString(i), int8(b.tp.Decimal))
  1280  		if err != nil {
  1281  			return err
  1282  		}
  1283  		if rhsIsDuration {
  1284  			result.SetNull(i, true)
  1285  			continue
  1286  		}
  1287  		d, isNull, err := calculateTimeDiff(stmtCtx, lhsTime, rhsTime)
  1288  		if err != nil {
  1289  			return err
  1290  		}
  1291  		if isNull {
  1292  			result.SetNull(i, true)
  1293  			continue
  1294  		}
  1295  		r64s[i] = d.Duration
  1296  	}
  1297  	return nil
  1298  }
  1299  
  1300  func (b *builtinTimeStringTimeDiffSig) vectorized() bool {
  1301  	return true
  1302  }
  1303  
  1304  func (b *builtinDurationStringTimeDiffSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1305  	n := input.NumEvents()
  1306  	result.ResizeGoDuration(n, false)
  1307  	r64s := result.GoDurations()
  1308  	buf0 := result
  1309  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
  1310  	if err != nil {
  1311  		return err
  1312  	}
  1313  	defer b.bufSlabPredictor.put(buf1)
  1314  
  1315  	if err := b.args[0].VecEvalDuration(b.ctx, input, buf0); err != nil {
  1316  		return err
  1317  	}
  1318  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
  1319  		return err
  1320  	}
  1321  
  1322  	result.MergeNulls(buf1)
  1323  	arg0 := buf0.GoDurations()
  1324  	var (
  1325  		lhs types.Duration
  1326  		rhs types.Duration
  1327  	)
  1328  	stmtCtx := b.ctx.GetStochastikVars().StmtCtx
  1329  	for i := 0; i < n; i++ {
  1330  		if result.IsNull(i) {
  1331  			continue
  1332  		}
  1333  		lhs.Duration = arg0[i]
  1334  		rhsDur, _, rhsIsDuration, err := convertStringToDuration(stmtCtx, buf1.GetString(i), int8(b.tp.Decimal))
  1335  		if err != nil {
  1336  			return err
  1337  		}
  1338  		if !rhsIsDuration {
  1339  			result.SetNull(i, true)
  1340  			continue
  1341  		}
  1342  		rhs = rhsDur
  1343  		d, isNull, err := calculateDurationTimeDiff(b.ctx, lhs, rhs)
  1344  		if err != nil {
  1345  			return err
  1346  		}
  1347  		if isNull {
  1348  			result.SetNull(i, true)
  1349  			continue
  1350  		}
  1351  		r64s[i] = d.Duration
  1352  	}
  1353  	return nil
  1354  }
  1355  
  1356  func (b *builtinDurationStringTimeDiffSig) vectorized() bool {
  1357  	return true
  1358  }
  1359  
  1360  func (b *builtinDurationDurationTimeDiffSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1361  	n := input.NumEvents()
  1362  	result.ResizeGoDuration(n, false)
  1363  	r64s := result.GoDurations()
  1364  	buf0 := result
  1365  	buf1, err := b.bufSlabPredictor.get(types.ETDuration, n)
  1366  	if err != nil {
  1367  		return err
  1368  	}
  1369  	defer b.bufSlabPredictor.put(buf1)
  1370  
  1371  	if err := b.args[0].VecEvalDuration(b.ctx, input, buf0); err != nil {
  1372  		return err
  1373  	}
  1374  	if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
  1375  		return err
  1376  	}
  1377  
  1378  	result.MergeNulls(buf1)
  1379  	arg0 := buf0.GoDurations()
  1380  	arg1 := buf1.GoDurations()
  1381  	var (
  1382  		lhs types.Duration
  1383  		rhs types.Duration
  1384  	)
  1385  	for i := 0; i < n; i++ {
  1386  		if result.IsNull(i) {
  1387  			continue
  1388  		}
  1389  		lhs.Duration = arg0[i]
  1390  		rhs.Duration = arg1[i]
  1391  		d, isNull, err := calculateDurationTimeDiff(b.ctx, lhs, rhs)
  1392  		if err != nil {
  1393  			return err
  1394  		}
  1395  		if isNull {
  1396  			result.SetNull(i, true)
  1397  			continue
  1398  		}
  1399  		r64s[i] = d.Duration
  1400  	}
  1401  	return nil
  1402  }
  1403  
  1404  func (b *builtinDurationDurationTimeDiffSig) vectorized() bool {
  1405  	return true
  1406  }
  1407  
  1408  func (b *builtinStringTimeTimeDiffSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1409  	n := input.NumEvents()
  1410  	result.ResizeGoDuration(n, false)
  1411  	r64s := result.GoDurations()
  1412  	buf0, err := b.bufSlabPredictor.get(types.ETString, n)
  1413  	if err != nil {
  1414  		return err
  1415  	}
  1416  	defer b.bufSlabPredictor.put(buf0)
  1417  
  1418  	buf1, err := b.bufSlabPredictor.get(types.ETDatetime, n)
  1419  	if err != nil {
  1420  		return err
  1421  	}
  1422  	defer b.bufSlabPredictor.put(buf1)
  1423  
  1424  	if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil {
  1425  		return err
  1426  	}
  1427  	if err := b.args[1].VecEvalTime(b.ctx, input, buf1); err != nil {
  1428  		return err
  1429  	}
  1430  
  1431  	result.MergeNulls(buf0, buf1)
  1432  	arg1 := buf1.Times()
  1433  	stmtCtx := b.ctx.GetStochastikVars().StmtCtx
  1434  	for i := 0; i < n; i++ {
  1435  		if result.IsNull(i) {
  1436  			continue
  1437  		}
  1438  		_, lhsTime, lhsIsDuration, err := convertStringToDuration(stmtCtx, buf0.GetString(i), int8(b.tp.Decimal))
  1439  		if err != nil {
  1440  			return err
  1441  		}
  1442  		if lhsIsDuration {
  1443  			result.SetNull(i, true)
  1444  			continue
  1445  		}
  1446  		rhsTime := arg1[i]
  1447  		d, isNull, err := calculateTimeDiff(stmtCtx, lhsTime, rhsTime)
  1448  		if err != nil {
  1449  			return err
  1450  		}
  1451  		if isNull {
  1452  			result.SetNull(i, true)
  1453  			continue
  1454  		}
  1455  		r64s[i] = d.Duration
  1456  	}
  1457  	return nil
  1458  }
  1459  
  1460  func (b *builtinStringTimeTimeDiffSig) vectorized() bool {
  1461  	return true
  1462  }
  1463  
  1464  func (b *builtinStringDurationTimeDiffSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1465  	n := input.NumEvents()
  1466  	result.ResizeGoDuration(n, false)
  1467  	r64s := result.GoDurations()
  1468  	buf1 := result
  1469  	buf0, err := b.bufSlabPredictor.get(types.ETString, n)
  1470  	if err != nil {
  1471  		return err
  1472  	}
  1473  	defer b.bufSlabPredictor.put(buf0)
  1474  
  1475  	if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil {
  1476  		return err
  1477  	}
  1478  	if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
  1479  		return err
  1480  	}
  1481  
  1482  	result.MergeNulls(buf0)
  1483  	arg1 := buf1.GoDurations()
  1484  	var (
  1485  		lhs types.Duration
  1486  		rhs types.Duration
  1487  	)
  1488  	stmtCtx := b.ctx.GetStochastikVars().StmtCtx
  1489  	for i := 0; i < n; i++ {
  1490  		if result.IsNull(i) {
  1491  			continue
  1492  		}
  1493  		lhsDur, _, lhsIsDuration, err := convertStringToDuration(stmtCtx, buf0.GetString(i), int8(b.tp.Decimal))
  1494  		if err != nil {
  1495  			return err
  1496  		}
  1497  		if !lhsIsDuration {
  1498  			result.SetNull(i, true)
  1499  			continue
  1500  		}
  1501  		lhs = lhsDur
  1502  		rhs.Duration = arg1[i]
  1503  		d, isNull, err := calculateDurationTimeDiff(b.ctx, lhs, rhs)
  1504  		if err != nil {
  1505  			return err
  1506  		}
  1507  		if isNull {
  1508  			result.SetNull(i, true)
  1509  			continue
  1510  		}
  1511  		r64s[i] = d.Duration
  1512  	}
  1513  	return nil
  1514  }
  1515  
  1516  func (b *builtinStringDurationTimeDiffSig) vectorized() bool {
  1517  	return true
  1518  }
  1519  
  1520  func (b *builtinStringStringTimeDiffSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1521  	n := input.NumEvents()
  1522  	result.ResizeGoDuration(n, false)
  1523  	r64s := result.GoDurations()
  1524  	buf0, err := b.bufSlabPredictor.get(types.ETString, n)
  1525  	if err != nil {
  1526  		return err
  1527  	}
  1528  	defer b.bufSlabPredictor.put(buf0)
  1529  
  1530  	buf1, err := b.bufSlabPredictor.get(types.ETString, n)
  1531  	if err != nil {
  1532  		return err
  1533  	}
  1534  	defer b.bufSlabPredictor.put(buf1)
  1535  
  1536  	if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil {
  1537  		return err
  1538  	}
  1539  	if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
  1540  		return err
  1541  	}
  1542  
  1543  	result.MergeNulls(buf0, buf1)
  1544  	stmtCtx := b.ctx.GetStochastikVars().StmtCtx
  1545  	for i := 0; i < n; i++ {
  1546  		if result.IsNull(i) {
  1547  			continue
  1548  		}
  1549  		lhsDur, lhsTime, lhsIsDuration, err := convertStringToDuration(stmtCtx, buf0.GetString(i), int8(b.tp.Decimal))
  1550  		if err != nil {
  1551  			return err
  1552  		}
  1553  		rhsDur, rhsTime, rhsIsDuration, err := convertStringToDuration(stmtCtx, buf1.GetString(i), int8(b.tp.Decimal))
  1554  		if err != nil {
  1555  			return err
  1556  		}
  1557  		if lhsIsDuration != rhsIsDuration {
  1558  			result.SetNull(i, true)
  1559  			continue
  1560  		}
  1561  		var (
  1562  			d      types.Duration
  1563  			isNull bool
  1564  		)
  1565  		if lhsIsDuration {
  1566  			d, isNull, err = calculateDurationTimeDiff(b.ctx, lhsDur, rhsDur)
  1567  		} else {
  1568  			d, isNull, err = calculateTimeDiff(stmtCtx, lhsTime, rhsTime)
  1569  		}
  1570  		if err != nil {
  1571  			return err
  1572  		}
  1573  		if isNull {
  1574  			result.SetNull(i, true)
  1575  			continue
  1576  		}
  1577  		r64s[i] = d.Duration
  1578  	}
  1579  	return nil
  1580  }
  1581  
  1582  func (b *builtinStringStringTimeDiffSig) vectorized() bool {
  1583  	return true
  1584  }
  1585  
  1586  func (b *builtinTimeTimeTimeDiffSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1587  	n := input.NumEvents()
  1588  	result.ResizeGoDuration(n, false)
  1589  	r64s := result.GoDurations()
  1590  	buf0, err := b.bufSlabPredictor.get(types.ETDatetime, n)
  1591  	if err != nil {
  1592  		return err
  1593  	}
  1594  	defer b.bufSlabPredictor.put(buf0)
  1595  
  1596  	buf1, err := b.bufSlabPredictor.get(types.ETDatetime, n)
  1597  	if err != nil {
  1598  		return err
  1599  	}
  1600  	defer b.bufSlabPredictor.put(buf1)
  1601  
  1602  	if err := b.args[0].VecEvalTime(b.ctx, input, buf0); err != nil {
  1603  		return err
  1604  	}
  1605  	if err := b.args[1].VecEvalTime(b.ctx, input, buf1); err != nil {
  1606  		return err
  1607  	}
  1608  
  1609  	result.MergeNulls(buf0, buf1)
  1610  	arg0 := buf0.Times()
  1611  	arg1 := buf1.Times()
  1612  	stmtCtx := b.ctx.GetStochastikVars().StmtCtx
  1613  	for i := 0; i < n; i++ {
  1614  		if result.IsNull(i) {
  1615  			continue
  1616  		}
  1617  		lhsTime := arg0[i]
  1618  		rhsTime := arg1[i]
  1619  		d, isNull, err := calculateTimeDiff(stmtCtx, lhsTime, rhsTime)
  1620  		if err != nil {
  1621  			return err
  1622  		}
  1623  		if isNull {
  1624  			result.SetNull(i, true)
  1625  			continue
  1626  		}
  1627  		r64s[i] = d.Duration
  1628  	}
  1629  	return nil
  1630  }
  1631  
  1632  func (b *builtinTimeTimeTimeDiffSig) vectorized() bool {
  1633  	return true
  1634  }
  1635  
  1636  func (b *builtinAddDateStringStringSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1637  	n := input.NumEvents()
  1638  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  1639  	if err != nil {
  1640  		return err
  1641  	}
  1642  	if isNull {
  1643  		result.ResizeTime(n, true)
  1644  		return nil
  1645  	}
  1646  
  1647  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  1648  	if err != nil {
  1649  		return err
  1650  	}
  1651  	defer b.bufSlabPredictor.put(intervalBuf)
  1652  	if err := b.vecGetIntervalFromString(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  1653  		return err
  1654  	}
  1655  
  1656  	if err := b.vecGetDateFromString(&b.baseBuiltinFunc, input, unit, result); err != nil {
  1657  		return err
  1658  	}
  1659  
  1660  	result.MergeNulls(intervalBuf)
  1661  	resDates := result.Times()
  1662  	for i := 0; i < n; i++ {
  1663  		if result.IsNull(i) {
  1664  			continue
  1665  		}
  1666  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  1667  		if err != nil {
  1668  			return err
  1669  		}
  1670  		if isNull {
  1671  			result.SetNull(i, true)
  1672  		} else {
  1673  			resDates[i] = resDate
  1674  		}
  1675  	}
  1676  	return nil
  1677  }
  1678  
  1679  func (b *builtinAddDateStringStringSig) vectorized() bool {
  1680  	return true
  1681  }
  1682  
  1683  func (b *builtinAddDateStringIntSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1684  	n := input.NumEvents()
  1685  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  1686  	if err != nil {
  1687  		return err
  1688  	}
  1689  	if isNull {
  1690  		result.ResizeTime(n, true)
  1691  		return nil
  1692  	}
  1693  
  1694  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  1695  	if err != nil {
  1696  		return err
  1697  	}
  1698  	defer b.bufSlabPredictor.put(intervalBuf)
  1699  	if err := b.vecGetIntervalFromInt(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  1700  		return err
  1701  	}
  1702  
  1703  	if err := b.vecGetDateFromString(&b.baseBuiltinFunc, input, unit, result); err != nil {
  1704  		return err
  1705  	}
  1706  
  1707  	result.MergeNulls(intervalBuf)
  1708  	resDates := result.Times()
  1709  	for i := 0; i < n; i++ {
  1710  		if result.IsNull(i) {
  1711  			continue
  1712  		}
  1713  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  1714  		if err != nil {
  1715  			return err
  1716  		}
  1717  		if isNull {
  1718  			result.SetNull(i, true)
  1719  		} else {
  1720  			resDates[i] = resDate
  1721  		}
  1722  	}
  1723  	return nil
  1724  }
  1725  
  1726  func (b *builtinAddDateStringIntSig) vectorized() bool {
  1727  	return true
  1728  }
  1729  
  1730  func (b *builtinAddDateStringRealSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1731  	n := input.NumEvents()
  1732  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  1733  	if err != nil {
  1734  		return err
  1735  	}
  1736  	if isNull {
  1737  		result.ResizeTime(n, true)
  1738  		return nil
  1739  	}
  1740  
  1741  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  1742  	if err != nil {
  1743  		return err
  1744  	}
  1745  	defer b.bufSlabPredictor.put(intervalBuf)
  1746  	if err := b.vecGetIntervalFromReal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  1747  		return err
  1748  	}
  1749  
  1750  	if err := b.vecGetDateFromString(&b.baseBuiltinFunc, input, unit, result); err != nil {
  1751  		return err
  1752  	}
  1753  
  1754  	result.MergeNulls(intervalBuf)
  1755  	resDates := result.Times()
  1756  	for i := 0; i < n; i++ {
  1757  		if result.IsNull(i) {
  1758  			continue
  1759  		}
  1760  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  1761  		if err != nil {
  1762  			return err
  1763  		}
  1764  		if isNull {
  1765  			result.SetNull(i, true)
  1766  		} else {
  1767  			resDates[i] = resDate
  1768  		}
  1769  	}
  1770  	return nil
  1771  }
  1772  
  1773  func (b *builtinAddDateStringRealSig) vectorized() bool {
  1774  	return true
  1775  }
  1776  
  1777  func (b *builtinAddDateStringDecimalSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1778  	n := input.NumEvents()
  1779  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  1780  	if err != nil {
  1781  		return err
  1782  	}
  1783  	if isNull {
  1784  		result.ResizeTime(n, true)
  1785  		return nil
  1786  	}
  1787  
  1788  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  1789  	if err != nil {
  1790  		return err
  1791  	}
  1792  	defer b.bufSlabPredictor.put(intervalBuf)
  1793  	if err := b.vecGetIntervalFromDecimal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  1794  		return err
  1795  	}
  1796  
  1797  	if err := b.vecGetDateFromString(&b.baseBuiltinFunc, input, unit, result); err != nil {
  1798  		return err
  1799  	}
  1800  
  1801  	result.MergeNulls(intervalBuf)
  1802  	resDates := result.Times()
  1803  	for i := 0; i < n; i++ {
  1804  		if result.IsNull(i) {
  1805  			continue
  1806  		}
  1807  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  1808  		if err != nil {
  1809  			return err
  1810  		}
  1811  		if isNull {
  1812  			result.SetNull(i, true)
  1813  		} else {
  1814  			resDates[i] = resDate
  1815  		}
  1816  	}
  1817  	return nil
  1818  }
  1819  
  1820  func (b *builtinAddDateStringDecimalSig) vectorized() bool {
  1821  	return true
  1822  }
  1823  
  1824  func (b *builtinAddDateIntStringSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1825  	n := input.NumEvents()
  1826  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  1827  	if err != nil {
  1828  		return err
  1829  	}
  1830  	if isNull {
  1831  		result.ResizeTime(n, true)
  1832  		return nil
  1833  	}
  1834  
  1835  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  1836  	if err != nil {
  1837  		return err
  1838  	}
  1839  	defer b.bufSlabPredictor.put(intervalBuf)
  1840  	if err := b.vecGetIntervalFromString(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  1841  		return err
  1842  	}
  1843  
  1844  	if err := b.vecGetDateFromInt(&b.baseBuiltinFunc, input, unit, result); err != nil {
  1845  		return err
  1846  	}
  1847  
  1848  	result.MergeNulls(intervalBuf)
  1849  	resDates := result.Times()
  1850  	for i := 0; i < n; i++ {
  1851  		if result.IsNull(i) {
  1852  			continue
  1853  		}
  1854  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  1855  		if err != nil {
  1856  			return err
  1857  		}
  1858  		if isNull {
  1859  			result.SetNull(i, true)
  1860  		} else {
  1861  			resDates[i] = resDate
  1862  		}
  1863  	}
  1864  	return nil
  1865  }
  1866  
  1867  func (b *builtinAddDateIntStringSig) vectorized() bool {
  1868  	return true
  1869  }
  1870  
  1871  func (b *builtinAddDateIntIntSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1872  	n := input.NumEvents()
  1873  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  1874  	if err != nil {
  1875  		return err
  1876  	}
  1877  	if isNull {
  1878  		result.ResizeTime(n, true)
  1879  		return nil
  1880  	}
  1881  
  1882  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  1883  	if err != nil {
  1884  		return err
  1885  	}
  1886  	defer b.bufSlabPredictor.put(intervalBuf)
  1887  	if err := b.vecGetIntervalFromInt(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  1888  		return err
  1889  	}
  1890  
  1891  	if err := b.vecGetDateFromInt(&b.baseBuiltinFunc, input, unit, result); err != nil {
  1892  		return err
  1893  	}
  1894  
  1895  	result.MergeNulls(intervalBuf)
  1896  	resDates := result.Times()
  1897  	for i := 0; i < n; i++ {
  1898  		if result.IsNull(i) {
  1899  			continue
  1900  		}
  1901  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  1902  		if err != nil {
  1903  			return err
  1904  		}
  1905  		if isNull {
  1906  			result.SetNull(i, true)
  1907  		} else {
  1908  			resDates[i] = resDate
  1909  		}
  1910  	}
  1911  	return nil
  1912  }
  1913  
  1914  func (b *builtinAddDateIntIntSig) vectorized() bool {
  1915  	return true
  1916  }
  1917  
  1918  func (b *builtinAddDateIntRealSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1919  	n := input.NumEvents()
  1920  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  1921  	if err != nil {
  1922  		return err
  1923  	}
  1924  	if isNull {
  1925  		result.ResizeTime(n, true)
  1926  		return nil
  1927  	}
  1928  
  1929  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  1930  	if err != nil {
  1931  		return err
  1932  	}
  1933  	defer b.bufSlabPredictor.put(intervalBuf)
  1934  	if err := b.vecGetIntervalFromReal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  1935  		return err
  1936  	}
  1937  
  1938  	if err := b.vecGetDateFromInt(&b.baseBuiltinFunc, input, unit, result); err != nil {
  1939  		return err
  1940  	}
  1941  
  1942  	result.MergeNulls(intervalBuf)
  1943  	resDates := result.Times()
  1944  	for i := 0; i < n; i++ {
  1945  		if result.IsNull(i) {
  1946  			continue
  1947  		}
  1948  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  1949  		if err != nil {
  1950  			return err
  1951  		}
  1952  		if isNull {
  1953  			result.SetNull(i, true)
  1954  		} else {
  1955  			resDates[i] = resDate
  1956  		}
  1957  	}
  1958  	return nil
  1959  }
  1960  
  1961  func (b *builtinAddDateIntRealSig) vectorized() bool {
  1962  	return true
  1963  }
  1964  
  1965  func (b *builtinAddDateIntDecimalSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  1966  	n := input.NumEvents()
  1967  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  1968  	if err != nil {
  1969  		return err
  1970  	}
  1971  	if isNull {
  1972  		result.ResizeTime(n, true)
  1973  		return nil
  1974  	}
  1975  
  1976  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  1977  	if err != nil {
  1978  		return err
  1979  	}
  1980  	defer b.bufSlabPredictor.put(intervalBuf)
  1981  	if err := b.vecGetIntervalFromDecimal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  1982  		return err
  1983  	}
  1984  
  1985  	if err := b.vecGetDateFromInt(&b.baseBuiltinFunc, input, unit, result); err != nil {
  1986  		return err
  1987  	}
  1988  
  1989  	result.MergeNulls(intervalBuf)
  1990  	resDates := result.Times()
  1991  	for i := 0; i < n; i++ {
  1992  		if result.IsNull(i) {
  1993  			continue
  1994  		}
  1995  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  1996  		if err != nil {
  1997  			return err
  1998  		}
  1999  		if isNull {
  2000  			result.SetNull(i, true)
  2001  		} else {
  2002  			resDates[i] = resDate
  2003  		}
  2004  	}
  2005  	return nil
  2006  }
  2007  
  2008  func (b *builtinAddDateIntDecimalSig) vectorized() bool {
  2009  	return true
  2010  }
  2011  
  2012  func (b *builtinAddDateDatetimeStringSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2013  	n := input.NumEvents()
  2014  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2015  	if err != nil {
  2016  		return err
  2017  	}
  2018  	if isNull {
  2019  		result.ResizeTime(n, true)
  2020  		return nil
  2021  	}
  2022  
  2023  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2024  	if err != nil {
  2025  		return err
  2026  	}
  2027  	defer b.bufSlabPredictor.put(intervalBuf)
  2028  	if err := b.vecGetIntervalFromString(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2029  		return err
  2030  	}
  2031  
  2032  	if err := b.vecGetDateFromDatetime(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2033  		return err
  2034  	}
  2035  
  2036  	result.MergeNulls(intervalBuf)
  2037  	resDates := result.Times()
  2038  	for i := 0; i < n; i++ {
  2039  		if result.IsNull(i) {
  2040  			continue
  2041  		}
  2042  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2043  		if err != nil {
  2044  			return err
  2045  		}
  2046  		if isNull {
  2047  			result.SetNull(i, true)
  2048  		} else {
  2049  			resDates[i] = resDate
  2050  		}
  2051  	}
  2052  	return nil
  2053  }
  2054  
  2055  func (b *builtinAddDateDatetimeStringSig) vectorized() bool {
  2056  	return true
  2057  }
  2058  
  2059  func (b *builtinAddDateDatetimeIntSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2060  	n := input.NumEvents()
  2061  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2062  	if err != nil {
  2063  		return err
  2064  	}
  2065  	if isNull {
  2066  		result.ResizeTime(n, true)
  2067  		return nil
  2068  	}
  2069  
  2070  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2071  	if err != nil {
  2072  		return err
  2073  	}
  2074  	defer b.bufSlabPredictor.put(intervalBuf)
  2075  	if err := b.vecGetIntervalFromInt(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2076  		return err
  2077  	}
  2078  
  2079  	if err := b.vecGetDateFromDatetime(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2080  		return err
  2081  	}
  2082  
  2083  	result.MergeNulls(intervalBuf)
  2084  	resDates := result.Times()
  2085  	for i := 0; i < n; i++ {
  2086  		if result.IsNull(i) {
  2087  			continue
  2088  		}
  2089  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2090  		if err != nil {
  2091  			return err
  2092  		}
  2093  		if isNull {
  2094  			result.SetNull(i, true)
  2095  		} else {
  2096  			resDates[i] = resDate
  2097  		}
  2098  	}
  2099  	return nil
  2100  }
  2101  
  2102  func (b *builtinAddDateDatetimeIntSig) vectorized() bool {
  2103  	return true
  2104  }
  2105  
  2106  func (b *builtinAddDateDatetimeRealSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2107  	n := input.NumEvents()
  2108  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2109  	if err != nil {
  2110  		return err
  2111  	}
  2112  	if isNull {
  2113  		result.ResizeTime(n, true)
  2114  		return nil
  2115  	}
  2116  
  2117  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2118  	if err != nil {
  2119  		return err
  2120  	}
  2121  	defer b.bufSlabPredictor.put(intervalBuf)
  2122  	if err := b.vecGetIntervalFromReal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2123  		return err
  2124  	}
  2125  
  2126  	if err := b.vecGetDateFromDatetime(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2127  		return err
  2128  	}
  2129  
  2130  	result.MergeNulls(intervalBuf)
  2131  	resDates := result.Times()
  2132  	for i := 0; i < n; i++ {
  2133  		if result.IsNull(i) {
  2134  			continue
  2135  		}
  2136  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2137  		if err != nil {
  2138  			return err
  2139  		}
  2140  		if isNull {
  2141  			result.SetNull(i, true)
  2142  		} else {
  2143  			resDates[i] = resDate
  2144  		}
  2145  	}
  2146  	return nil
  2147  }
  2148  
  2149  func (b *builtinAddDateDatetimeRealSig) vectorized() bool {
  2150  	return true
  2151  }
  2152  
  2153  func (b *builtinAddDateDatetimeDecimalSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2154  	n := input.NumEvents()
  2155  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2156  	if err != nil {
  2157  		return err
  2158  	}
  2159  	if isNull {
  2160  		result.ResizeTime(n, true)
  2161  		return nil
  2162  	}
  2163  
  2164  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2165  	if err != nil {
  2166  		return err
  2167  	}
  2168  	defer b.bufSlabPredictor.put(intervalBuf)
  2169  	if err := b.vecGetIntervalFromDecimal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2170  		return err
  2171  	}
  2172  
  2173  	if err := b.vecGetDateFromDatetime(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2174  		return err
  2175  	}
  2176  
  2177  	result.MergeNulls(intervalBuf)
  2178  	resDates := result.Times()
  2179  	for i := 0; i < n; i++ {
  2180  		if result.IsNull(i) {
  2181  			continue
  2182  		}
  2183  		resDate, isNull, err := b.add(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2184  		if err != nil {
  2185  			return err
  2186  		}
  2187  		if isNull {
  2188  			result.SetNull(i, true)
  2189  		} else {
  2190  			resDates[i] = resDate
  2191  		}
  2192  	}
  2193  	return nil
  2194  }
  2195  
  2196  func (b *builtinAddDateDatetimeDecimalSig) vectorized() bool {
  2197  	return true
  2198  }
  2199  
  2200  func (b *builtinAddDateDurationStringSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2201  	n := input.NumEvents()
  2202  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2203  	if err != nil {
  2204  		return err
  2205  	}
  2206  	if isNull {
  2207  		result.ResizeGoDuration(n, true)
  2208  		return nil
  2209  	}
  2210  
  2211  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2212  	if err != nil {
  2213  		return err
  2214  	}
  2215  	defer b.bufSlabPredictor.put(intervalBuf)
  2216  	if err := b.vecGetIntervalFromString(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2217  		return err
  2218  	}
  2219  
  2220  	result.ResizeGoDuration(n, false)
  2221  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
  2222  		return err
  2223  	}
  2224  
  2225  	result.MergeNulls(intervalBuf)
  2226  	resDurations := result.GoDurations()
  2227  	iterDuration := types.Duration{Fsp: types.MaxFsp}
  2228  	for i := 0; i < n; i++ {
  2229  		if result.IsNull(i) {
  2230  			continue
  2231  		}
  2232  		iterDuration.Duration = resDurations[i]
  2233  		resDuration, isNull, err := b.addDuration(b.ctx, iterDuration, intervalBuf.GetString(i), unit)
  2234  		if err != nil {
  2235  			return err
  2236  		}
  2237  		if isNull {
  2238  			result.SetNull(i, true)
  2239  		} else {
  2240  			resDurations[i] = resDuration.Duration
  2241  		}
  2242  	}
  2243  	return nil
  2244  }
  2245  
  2246  func (b *builtinAddDateDurationStringSig) vectorized() bool {
  2247  	return true
  2248  }
  2249  
  2250  func (b *builtinAddDateDurationIntSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2251  	n := input.NumEvents()
  2252  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2253  	if err != nil {
  2254  		return err
  2255  	}
  2256  	if isNull {
  2257  		result.ResizeGoDuration(n, true)
  2258  		return nil
  2259  	}
  2260  
  2261  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2262  	if err != nil {
  2263  		return err
  2264  	}
  2265  	defer b.bufSlabPredictor.put(intervalBuf)
  2266  	if err := b.vecGetIntervalFromInt(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2267  		return err
  2268  	}
  2269  
  2270  	result.ResizeGoDuration(n, false)
  2271  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
  2272  		return err
  2273  	}
  2274  
  2275  	result.MergeNulls(intervalBuf)
  2276  	resDurations := result.GoDurations()
  2277  	iterDuration := types.Duration{Fsp: types.MaxFsp}
  2278  	for i := 0; i < n; i++ {
  2279  		if result.IsNull(i) {
  2280  			continue
  2281  		}
  2282  		iterDuration.Duration = resDurations[i]
  2283  		resDuration, isNull, err := b.addDuration(b.ctx, iterDuration, intervalBuf.GetString(i), unit)
  2284  		if err != nil {
  2285  			return err
  2286  		}
  2287  		if isNull {
  2288  			result.SetNull(i, true)
  2289  		} else {
  2290  			resDurations[i] = resDuration.Duration
  2291  		}
  2292  	}
  2293  	return nil
  2294  }
  2295  
  2296  func (b *builtinAddDateDurationIntSig) vectorized() bool {
  2297  	return true
  2298  }
  2299  
  2300  func (b *builtinAddDateDurationRealSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2301  	n := input.NumEvents()
  2302  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2303  	if err != nil {
  2304  		return err
  2305  	}
  2306  	if isNull {
  2307  		result.ResizeGoDuration(n, true)
  2308  		return nil
  2309  	}
  2310  
  2311  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2312  	if err != nil {
  2313  		return err
  2314  	}
  2315  	defer b.bufSlabPredictor.put(intervalBuf)
  2316  	if err := b.vecGetIntervalFromReal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2317  		return err
  2318  	}
  2319  
  2320  	result.ResizeGoDuration(n, false)
  2321  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
  2322  		return err
  2323  	}
  2324  
  2325  	result.MergeNulls(intervalBuf)
  2326  	resDurations := result.GoDurations()
  2327  	iterDuration := types.Duration{Fsp: types.MaxFsp}
  2328  	for i := 0; i < n; i++ {
  2329  		if result.IsNull(i) {
  2330  			continue
  2331  		}
  2332  		iterDuration.Duration = resDurations[i]
  2333  		resDuration, isNull, err := b.addDuration(b.ctx, iterDuration, intervalBuf.GetString(i), unit)
  2334  		if err != nil {
  2335  			return err
  2336  		}
  2337  		if isNull {
  2338  			result.SetNull(i, true)
  2339  		} else {
  2340  			resDurations[i] = resDuration.Duration
  2341  		}
  2342  	}
  2343  	return nil
  2344  }
  2345  
  2346  func (b *builtinAddDateDurationRealSig) vectorized() bool {
  2347  	return true
  2348  }
  2349  
  2350  func (b *builtinAddDateDurationDecimalSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2351  	n := input.NumEvents()
  2352  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2353  	if err != nil {
  2354  		return err
  2355  	}
  2356  	if isNull {
  2357  		result.ResizeGoDuration(n, true)
  2358  		return nil
  2359  	}
  2360  
  2361  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2362  	if err != nil {
  2363  		return err
  2364  	}
  2365  	defer b.bufSlabPredictor.put(intervalBuf)
  2366  	if err := b.vecGetIntervalFromDecimal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2367  		return err
  2368  	}
  2369  
  2370  	result.ResizeGoDuration(n, false)
  2371  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
  2372  		return err
  2373  	}
  2374  
  2375  	result.MergeNulls(intervalBuf)
  2376  	resDurations := result.GoDurations()
  2377  	iterDuration := types.Duration{Fsp: types.MaxFsp}
  2378  	for i := 0; i < n; i++ {
  2379  		if result.IsNull(i) {
  2380  			continue
  2381  		}
  2382  		iterDuration.Duration = resDurations[i]
  2383  		resDuration, isNull, err := b.addDuration(b.ctx, iterDuration, intervalBuf.GetString(i), unit)
  2384  		if err != nil {
  2385  			return err
  2386  		}
  2387  		if isNull {
  2388  			result.SetNull(i, true)
  2389  		} else {
  2390  			resDurations[i] = resDuration.Duration
  2391  		}
  2392  	}
  2393  	return nil
  2394  }
  2395  
  2396  func (b *builtinAddDateDurationDecimalSig) vectorized() bool {
  2397  	return true
  2398  }
  2399  
  2400  func (b *builtinSubDateStringStringSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2401  	n := input.NumEvents()
  2402  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2403  	if err != nil {
  2404  		return err
  2405  	}
  2406  	if isNull {
  2407  		result.ResizeTime(n, true)
  2408  		return nil
  2409  	}
  2410  
  2411  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2412  	if err != nil {
  2413  		return err
  2414  	}
  2415  	defer b.bufSlabPredictor.put(intervalBuf)
  2416  	if err := b.vecGetIntervalFromString(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2417  		return err
  2418  	}
  2419  
  2420  	if err := b.vecGetDateFromString(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2421  		return err
  2422  	}
  2423  
  2424  	result.MergeNulls(intervalBuf)
  2425  	resDates := result.Times()
  2426  	for i := 0; i < n; i++ {
  2427  		if result.IsNull(i) {
  2428  			continue
  2429  		}
  2430  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2431  		if err != nil {
  2432  			return err
  2433  		}
  2434  		if isNull {
  2435  			result.SetNull(i, true)
  2436  		} else {
  2437  			resDates[i] = resDate
  2438  		}
  2439  	}
  2440  	return nil
  2441  }
  2442  
  2443  func (b *builtinSubDateStringStringSig) vectorized() bool {
  2444  	return true
  2445  }
  2446  
  2447  func (b *builtinSubDateStringIntSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2448  	n := input.NumEvents()
  2449  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2450  	if err != nil {
  2451  		return err
  2452  	}
  2453  	if isNull {
  2454  		result.ResizeTime(n, true)
  2455  		return nil
  2456  	}
  2457  
  2458  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2459  	if err != nil {
  2460  		return err
  2461  	}
  2462  	defer b.bufSlabPredictor.put(intervalBuf)
  2463  	if err := b.vecGetIntervalFromInt(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2464  		return err
  2465  	}
  2466  
  2467  	if err := b.vecGetDateFromString(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2468  		return err
  2469  	}
  2470  
  2471  	result.MergeNulls(intervalBuf)
  2472  	resDates := result.Times()
  2473  	for i := 0; i < n; i++ {
  2474  		if result.IsNull(i) {
  2475  			continue
  2476  		}
  2477  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2478  		if err != nil {
  2479  			return err
  2480  		}
  2481  		if isNull {
  2482  			result.SetNull(i, true)
  2483  		} else {
  2484  			resDates[i] = resDate
  2485  		}
  2486  	}
  2487  	return nil
  2488  }
  2489  
  2490  func (b *builtinSubDateStringIntSig) vectorized() bool {
  2491  	return true
  2492  }
  2493  
  2494  func (b *builtinSubDateStringRealSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2495  	n := input.NumEvents()
  2496  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2497  	if err != nil {
  2498  		return err
  2499  	}
  2500  	if isNull {
  2501  		result.ResizeTime(n, true)
  2502  		return nil
  2503  	}
  2504  
  2505  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2506  	if err != nil {
  2507  		return err
  2508  	}
  2509  	defer b.bufSlabPredictor.put(intervalBuf)
  2510  	if err := b.vecGetIntervalFromReal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2511  		return err
  2512  	}
  2513  
  2514  	if err := b.vecGetDateFromString(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2515  		return err
  2516  	}
  2517  
  2518  	result.MergeNulls(intervalBuf)
  2519  	resDates := result.Times()
  2520  	for i := 0; i < n; i++ {
  2521  		if result.IsNull(i) {
  2522  			continue
  2523  		}
  2524  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2525  		if err != nil {
  2526  			return err
  2527  		}
  2528  		if isNull {
  2529  			result.SetNull(i, true)
  2530  		} else {
  2531  			resDates[i] = resDate
  2532  		}
  2533  	}
  2534  	return nil
  2535  }
  2536  
  2537  func (b *builtinSubDateStringRealSig) vectorized() bool {
  2538  	return true
  2539  }
  2540  
  2541  func (b *builtinSubDateStringDecimalSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2542  	n := input.NumEvents()
  2543  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2544  	if err != nil {
  2545  		return err
  2546  	}
  2547  	if isNull {
  2548  		result.ResizeTime(n, true)
  2549  		return nil
  2550  	}
  2551  
  2552  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2553  	if err != nil {
  2554  		return err
  2555  	}
  2556  	defer b.bufSlabPredictor.put(intervalBuf)
  2557  	if err := b.vecGetIntervalFromDecimal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2558  		return err
  2559  	}
  2560  
  2561  	if err := b.vecGetDateFromString(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2562  		return err
  2563  	}
  2564  
  2565  	result.MergeNulls(intervalBuf)
  2566  	resDates := result.Times()
  2567  	for i := 0; i < n; i++ {
  2568  		if result.IsNull(i) {
  2569  			continue
  2570  		}
  2571  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2572  		if err != nil {
  2573  			return err
  2574  		}
  2575  		if isNull {
  2576  			result.SetNull(i, true)
  2577  		} else {
  2578  			resDates[i] = resDate
  2579  		}
  2580  	}
  2581  	return nil
  2582  }
  2583  
  2584  func (b *builtinSubDateStringDecimalSig) vectorized() bool {
  2585  	return true
  2586  }
  2587  
  2588  func (b *builtinSubDateIntStringSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2589  	n := input.NumEvents()
  2590  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2591  	if err != nil {
  2592  		return err
  2593  	}
  2594  	if isNull {
  2595  		result.ResizeTime(n, true)
  2596  		return nil
  2597  	}
  2598  
  2599  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2600  	if err != nil {
  2601  		return err
  2602  	}
  2603  	defer b.bufSlabPredictor.put(intervalBuf)
  2604  	if err := b.vecGetIntervalFromString(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2605  		return err
  2606  	}
  2607  
  2608  	if err := b.vecGetDateFromInt(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2609  		return err
  2610  	}
  2611  
  2612  	result.MergeNulls(intervalBuf)
  2613  	resDates := result.Times()
  2614  	for i := 0; i < n; i++ {
  2615  		if result.IsNull(i) {
  2616  			continue
  2617  		}
  2618  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2619  		if err != nil {
  2620  			return err
  2621  		}
  2622  		if isNull {
  2623  			result.SetNull(i, true)
  2624  		} else {
  2625  			resDates[i] = resDate
  2626  		}
  2627  	}
  2628  	return nil
  2629  }
  2630  
  2631  func (b *builtinSubDateIntStringSig) vectorized() bool {
  2632  	return true
  2633  }
  2634  
  2635  func (b *builtinSubDateIntIntSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2636  	n := input.NumEvents()
  2637  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2638  	if err != nil {
  2639  		return err
  2640  	}
  2641  	if isNull {
  2642  		result.ResizeTime(n, true)
  2643  		return nil
  2644  	}
  2645  
  2646  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2647  	if err != nil {
  2648  		return err
  2649  	}
  2650  	defer b.bufSlabPredictor.put(intervalBuf)
  2651  	if err := b.vecGetIntervalFromInt(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2652  		return err
  2653  	}
  2654  
  2655  	if err := b.vecGetDateFromInt(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2656  		return err
  2657  	}
  2658  
  2659  	result.MergeNulls(intervalBuf)
  2660  	resDates := result.Times()
  2661  	for i := 0; i < n; i++ {
  2662  		if result.IsNull(i) {
  2663  			continue
  2664  		}
  2665  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2666  		if err != nil {
  2667  			return err
  2668  		}
  2669  		if isNull {
  2670  			result.SetNull(i, true)
  2671  		} else {
  2672  			resDates[i] = resDate
  2673  		}
  2674  	}
  2675  	return nil
  2676  }
  2677  
  2678  func (b *builtinSubDateIntIntSig) vectorized() bool {
  2679  	return true
  2680  }
  2681  
  2682  func (b *builtinSubDateIntRealSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2683  	n := input.NumEvents()
  2684  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2685  	if err != nil {
  2686  		return err
  2687  	}
  2688  	if isNull {
  2689  		result.ResizeTime(n, true)
  2690  		return nil
  2691  	}
  2692  
  2693  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2694  	if err != nil {
  2695  		return err
  2696  	}
  2697  	defer b.bufSlabPredictor.put(intervalBuf)
  2698  	if err := b.vecGetIntervalFromReal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2699  		return err
  2700  	}
  2701  
  2702  	if err := b.vecGetDateFromInt(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2703  		return err
  2704  	}
  2705  
  2706  	result.MergeNulls(intervalBuf)
  2707  	resDates := result.Times()
  2708  	for i := 0; i < n; i++ {
  2709  		if result.IsNull(i) {
  2710  			continue
  2711  		}
  2712  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2713  		if err != nil {
  2714  			return err
  2715  		}
  2716  		if isNull {
  2717  			result.SetNull(i, true)
  2718  		} else {
  2719  			resDates[i] = resDate
  2720  		}
  2721  	}
  2722  	return nil
  2723  }
  2724  
  2725  func (b *builtinSubDateIntRealSig) vectorized() bool {
  2726  	return true
  2727  }
  2728  
  2729  func (b *builtinSubDateIntDecimalSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2730  	n := input.NumEvents()
  2731  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2732  	if err != nil {
  2733  		return err
  2734  	}
  2735  	if isNull {
  2736  		result.ResizeTime(n, true)
  2737  		return nil
  2738  	}
  2739  
  2740  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2741  	if err != nil {
  2742  		return err
  2743  	}
  2744  	defer b.bufSlabPredictor.put(intervalBuf)
  2745  	if err := b.vecGetIntervalFromDecimal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2746  		return err
  2747  	}
  2748  
  2749  	if err := b.vecGetDateFromInt(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2750  		return err
  2751  	}
  2752  
  2753  	result.MergeNulls(intervalBuf)
  2754  	resDates := result.Times()
  2755  	for i := 0; i < n; i++ {
  2756  		if result.IsNull(i) {
  2757  			continue
  2758  		}
  2759  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2760  		if err != nil {
  2761  			return err
  2762  		}
  2763  		if isNull {
  2764  			result.SetNull(i, true)
  2765  		} else {
  2766  			resDates[i] = resDate
  2767  		}
  2768  	}
  2769  	return nil
  2770  }
  2771  
  2772  func (b *builtinSubDateIntDecimalSig) vectorized() bool {
  2773  	return true
  2774  }
  2775  
  2776  func (b *builtinSubDateDatetimeStringSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2777  	n := input.NumEvents()
  2778  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2779  	if err != nil {
  2780  		return err
  2781  	}
  2782  	if isNull {
  2783  		result.ResizeTime(n, true)
  2784  		return nil
  2785  	}
  2786  
  2787  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2788  	if err != nil {
  2789  		return err
  2790  	}
  2791  	defer b.bufSlabPredictor.put(intervalBuf)
  2792  	if err := b.vecGetIntervalFromString(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2793  		return err
  2794  	}
  2795  
  2796  	if err := b.vecGetDateFromDatetime(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2797  		return err
  2798  	}
  2799  
  2800  	result.MergeNulls(intervalBuf)
  2801  	resDates := result.Times()
  2802  	for i := 0; i < n; i++ {
  2803  		if result.IsNull(i) {
  2804  			continue
  2805  		}
  2806  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2807  		if err != nil {
  2808  			return err
  2809  		}
  2810  		if isNull {
  2811  			result.SetNull(i, true)
  2812  		} else {
  2813  			resDates[i] = resDate
  2814  		}
  2815  	}
  2816  	return nil
  2817  }
  2818  
  2819  func (b *builtinSubDateDatetimeStringSig) vectorized() bool {
  2820  	return true
  2821  }
  2822  
  2823  func (b *builtinSubDateDatetimeIntSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2824  	n := input.NumEvents()
  2825  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2826  	if err != nil {
  2827  		return err
  2828  	}
  2829  	if isNull {
  2830  		result.ResizeTime(n, true)
  2831  		return nil
  2832  	}
  2833  
  2834  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2835  	if err != nil {
  2836  		return err
  2837  	}
  2838  	defer b.bufSlabPredictor.put(intervalBuf)
  2839  	if err := b.vecGetIntervalFromInt(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2840  		return err
  2841  	}
  2842  
  2843  	if err := b.vecGetDateFromDatetime(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2844  		return err
  2845  	}
  2846  
  2847  	result.MergeNulls(intervalBuf)
  2848  	resDates := result.Times()
  2849  	for i := 0; i < n; i++ {
  2850  		if result.IsNull(i) {
  2851  			continue
  2852  		}
  2853  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2854  		if err != nil {
  2855  			return err
  2856  		}
  2857  		if isNull {
  2858  			result.SetNull(i, true)
  2859  		} else {
  2860  			resDates[i] = resDate
  2861  		}
  2862  	}
  2863  	return nil
  2864  }
  2865  
  2866  func (b *builtinSubDateDatetimeIntSig) vectorized() bool {
  2867  	return true
  2868  }
  2869  
  2870  func (b *builtinSubDateDatetimeRealSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2871  	n := input.NumEvents()
  2872  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2873  	if err != nil {
  2874  		return err
  2875  	}
  2876  	if isNull {
  2877  		result.ResizeTime(n, true)
  2878  		return nil
  2879  	}
  2880  
  2881  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2882  	if err != nil {
  2883  		return err
  2884  	}
  2885  	defer b.bufSlabPredictor.put(intervalBuf)
  2886  	if err := b.vecGetIntervalFromReal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2887  		return err
  2888  	}
  2889  
  2890  	if err := b.vecGetDateFromDatetime(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2891  		return err
  2892  	}
  2893  
  2894  	result.MergeNulls(intervalBuf)
  2895  	resDates := result.Times()
  2896  	for i := 0; i < n; i++ {
  2897  		if result.IsNull(i) {
  2898  			continue
  2899  		}
  2900  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2901  		if err != nil {
  2902  			return err
  2903  		}
  2904  		if isNull {
  2905  			result.SetNull(i, true)
  2906  		} else {
  2907  			resDates[i] = resDate
  2908  		}
  2909  	}
  2910  	return nil
  2911  }
  2912  
  2913  func (b *builtinSubDateDatetimeRealSig) vectorized() bool {
  2914  	return true
  2915  }
  2916  
  2917  func (b *builtinSubDateDatetimeDecimalSig) vecEvalTime(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2918  	n := input.NumEvents()
  2919  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2920  	if err != nil {
  2921  		return err
  2922  	}
  2923  	if isNull {
  2924  		result.ResizeTime(n, true)
  2925  		return nil
  2926  	}
  2927  
  2928  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2929  	if err != nil {
  2930  		return err
  2931  	}
  2932  	defer b.bufSlabPredictor.put(intervalBuf)
  2933  	if err := b.vecGetIntervalFromDecimal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2934  		return err
  2935  	}
  2936  
  2937  	if err := b.vecGetDateFromDatetime(&b.baseBuiltinFunc, input, unit, result); err != nil {
  2938  		return err
  2939  	}
  2940  
  2941  	result.MergeNulls(intervalBuf)
  2942  	resDates := result.Times()
  2943  	for i := 0; i < n; i++ {
  2944  		if result.IsNull(i) {
  2945  			continue
  2946  		}
  2947  		resDate, isNull, err := b.sub(b.ctx, resDates[i], intervalBuf.GetString(i), unit)
  2948  		if err != nil {
  2949  			return err
  2950  		}
  2951  		if isNull {
  2952  			result.SetNull(i, true)
  2953  		} else {
  2954  			resDates[i] = resDate
  2955  		}
  2956  	}
  2957  	return nil
  2958  }
  2959  
  2960  func (b *builtinSubDateDatetimeDecimalSig) vectorized() bool {
  2961  	return true
  2962  }
  2963  
  2964  func (b *builtinSubDateDurationStringSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  2965  	n := input.NumEvents()
  2966  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  2967  	if err != nil {
  2968  		return err
  2969  	}
  2970  	if isNull {
  2971  		result.ResizeGoDuration(n, true)
  2972  		return nil
  2973  	}
  2974  
  2975  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  2976  	if err != nil {
  2977  		return err
  2978  	}
  2979  	defer b.bufSlabPredictor.put(intervalBuf)
  2980  	if err := b.vecGetIntervalFromString(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  2981  		return err
  2982  	}
  2983  
  2984  	result.ResizeGoDuration(n, false)
  2985  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
  2986  		return err
  2987  	}
  2988  
  2989  	result.MergeNulls(intervalBuf)
  2990  	resDurations := result.GoDurations()
  2991  	iterDuration := types.Duration{Fsp: types.MaxFsp}
  2992  	for i := 0; i < n; i++ {
  2993  		if result.IsNull(i) {
  2994  			continue
  2995  		}
  2996  		iterDuration.Duration = resDurations[i]
  2997  		resDuration, isNull, err := b.subDuration(b.ctx, iterDuration, intervalBuf.GetString(i), unit)
  2998  		if err != nil {
  2999  			return err
  3000  		}
  3001  		if isNull {
  3002  			result.SetNull(i, true)
  3003  		} else {
  3004  			resDurations[i] = resDuration.Duration
  3005  		}
  3006  	}
  3007  	return nil
  3008  }
  3009  
  3010  func (b *builtinSubDateDurationStringSig) vectorized() bool {
  3011  	return true
  3012  }
  3013  
  3014  func (b *builtinSubDateDurationIntSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  3015  	n := input.NumEvents()
  3016  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  3017  	if err != nil {
  3018  		return err
  3019  	}
  3020  	if isNull {
  3021  		result.ResizeGoDuration(n, true)
  3022  		return nil
  3023  	}
  3024  
  3025  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  3026  	if err != nil {
  3027  		return err
  3028  	}
  3029  	defer b.bufSlabPredictor.put(intervalBuf)
  3030  	if err := b.vecGetIntervalFromInt(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  3031  		return err
  3032  	}
  3033  
  3034  	result.ResizeGoDuration(n, false)
  3035  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
  3036  		return err
  3037  	}
  3038  
  3039  	result.MergeNulls(intervalBuf)
  3040  	resDurations := result.GoDurations()
  3041  	iterDuration := types.Duration{Fsp: types.MaxFsp}
  3042  	for i := 0; i < n; i++ {
  3043  		if result.IsNull(i) {
  3044  			continue
  3045  		}
  3046  		iterDuration.Duration = resDurations[i]
  3047  		resDuration, isNull, err := b.subDuration(b.ctx, iterDuration, intervalBuf.GetString(i), unit)
  3048  		if err != nil {
  3049  			return err
  3050  		}
  3051  		if isNull {
  3052  			result.SetNull(i, true)
  3053  		} else {
  3054  			resDurations[i] = resDuration.Duration
  3055  		}
  3056  	}
  3057  	return nil
  3058  }
  3059  
  3060  func (b *builtinSubDateDurationIntSig) vectorized() bool {
  3061  	return true
  3062  }
  3063  
  3064  func (b *builtinSubDateDurationRealSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  3065  	n := input.NumEvents()
  3066  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  3067  	if err != nil {
  3068  		return err
  3069  	}
  3070  	if isNull {
  3071  		result.ResizeGoDuration(n, true)
  3072  		return nil
  3073  	}
  3074  
  3075  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  3076  	if err != nil {
  3077  		return err
  3078  	}
  3079  	defer b.bufSlabPredictor.put(intervalBuf)
  3080  	if err := b.vecGetIntervalFromReal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  3081  		return err
  3082  	}
  3083  
  3084  	result.ResizeGoDuration(n, false)
  3085  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
  3086  		return err
  3087  	}
  3088  
  3089  	result.MergeNulls(intervalBuf)
  3090  	resDurations := result.GoDurations()
  3091  	iterDuration := types.Duration{Fsp: types.MaxFsp}
  3092  	for i := 0; i < n; i++ {
  3093  		if result.IsNull(i) {
  3094  			continue
  3095  		}
  3096  		iterDuration.Duration = resDurations[i]
  3097  		resDuration, isNull, err := b.subDuration(b.ctx, iterDuration, intervalBuf.GetString(i), unit)
  3098  		if err != nil {
  3099  			return err
  3100  		}
  3101  		if isNull {
  3102  			result.SetNull(i, true)
  3103  		} else {
  3104  			resDurations[i] = resDuration.Duration
  3105  		}
  3106  	}
  3107  	return nil
  3108  }
  3109  
  3110  func (b *builtinSubDateDurationRealSig) vectorized() bool {
  3111  	return true
  3112  }
  3113  
  3114  func (b *builtinSubDateDurationDecimalSig) vecEvalDuration(input *chunk.Chunk, result *chunk.DeferredCauset) error {
  3115  	n := input.NumEvents()
  3116  	unit, isNull, err := b.args[2].EvalString(b.ctx, chunk.Event{})
  3117  	if err != nil {
  3118  		return err
  3119  	}
  3120  	if isNull {
  3121  		result.ResizeGoDuration(n, true)
  3122  		return nil
  3123  	}
  3124  
  3125  	intervalBuf, err := b.bufSlabPredictor.get(types.ETString, n)
  3126  	if err != nil {
  3127  		return err
  3128  	}
  3129  	defer b.bufSlabPredictor.put(intervalBuf)
  3130  	if err := b.vecGetIntervalFromDecimal(&b.baseBuiltinFunc, input, unit, intervalBuf); err != nil {
  3131  		return err
  3132  	}
  3133  
  3134  	result.ResizeGoDuration(n, false)
  3135  	if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
  3136  		return err
  3137  	}
  3138  
  3139  	result.MergeNulls(intervalBuf)
  3140  	resDurations := result.GoDurations()
  3141  	iterDuration := types.Duration{Fsp: types.MaxFsp}
  3142  	for i := 0; i < n; i++ {
  3143  		if result.IsNull(i) {
  3144  			continue
  3145  		}
  3146  		iterDuration.Duration = resDurations[i]
  3147  		resDuration, isNull, err := b.subDuration(b.ctx, iterDuration, intervalBuf.GetString(i), unit)
  3148  		if err != nil {
  3149  			return err
  3150  		}
  3151  		if isNull {
  3152  			result.SetNull(i, true)
  3153  		} else {
  3154  			resDurations[i] = resDuration.Duration
  3155  		}
  3156  	}
  3157  	return nil
  3158  }
  3159  
  3160  func (b *builtinSubDateDurationDecimalSig) vectorized() bool {
  3161  	return true
  3162  }