github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/plan/function/list_builtIn.go (about)

     1  // Copyright 2021 - 2022 Matrix Origin
     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  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package function
    16  
    17  import (
    18  	"fmt"
    19  
    20  	"github.com/matrixorigin/matrixone/pkg/common/moerr"
    21  	"github.com/matrixorigin/matrixone/pkg/container/types"
    22  	"github.com/matrixorigin/matrixone/pkg/container/vector"
    23  	"github.com/matrixorigin/matrixone/pkg/pb/plan"
    24  	"github.com/matrixorigin/matrixone/pkg/sql/plan/function/ctl"
    25  	"github.com/matrixorigin/matrixone/pkg/sql/plan/function/functionUtil"
    26  	"github.com/matrixorigin/matrixone/pkg/vm/process"
    27  )
    28  
    29  var supportedStringBuiltIns = []FuncNew{
    30  	// function `ascii`
    31  	{
    32  		functionId: ASCII,
    33  		class:      plan.Function_STRICT,
    34  		layout:     STANDARD_FUNCTION,
    35  		checkFn:    fixedTypeMatch,
    36  
    37  		// I think we can just set them as one overload but not so much.
    38  		// but if so, we should rewrite a `checkFn` for this function.
    39  		// maybe you can see how I refactor the +, -, cast and so on.
    40  		// but I just do the simple copy here.
    41  		Overloads: []overload{
    42  			{
    43  				overloadId: 0,
    44  				args:       []types.T{types.T_varchar},
    45  				retType: func(parameters []types.Type) types.Type {
    46  					return types.T_uint8.ToType()
    47  				},
    48  				newOp: func() executeLogicOfOverload {
    49  					return AsciiString
    50  				},
    51  			},
    52  			{
    53  				overloadId: 1,
    54  				args:       []types.T{types.T_char},
    55  				retType: func(parameters []types.Type) types.Type {
    56  					return types.T_uint8.ToType()
    57  				},
    58  				newOp: func() executeLogicOfOverload {
    59  					return AsciiString
    60  				},
    61  			},
    62  			{
    63  				overloadId: 2,
    64  				args:       []types.T{types.T_text},
    65  				retType: func(parameters []types.Type) types.Type {
    66  					return types.T_uint8.ToType()
    67  				},
    68  				newOp: func() executeLogicOfOverload {
    69  					return AsciiString
    70  				},
    71  			},
    72  			{
    73  				overloadId: 3,
    74  				args:       []types.T{types.T_int8},
    75  				retType: func(parameters []types.Type) types.Type {
    76  					return types.T_uint8.ToType()
    77  				},
    78  				newOp: func() executeLogicOfOverload {
    79  					return AsciiInt[int8]
    80  				},
    81  			},
    82  			{
    83  				overloadId: 4,
    84  				args:       []types.T{types.T_int16},
    85  				retType: func(parameters []types.Type) types.Type {
    86  					return types.T_uint8.ToType()
    87  				},
    88  				newOp: func() executeLogicOfOverload {
    89  					return AsciiInt[int16]
    90  				},
    91  			},
    92  			{
    93  				overloadId: 5,
    94  				args:       []types.T{types.T_int32},
    95  				retType: func(parameters []types.Type) types.Type {
    96  					return types.T_uint8.ToType()
    97  				},
    98  				newOp: func() executeLogicOfOverload {
    99  					return AsciiInt[int32]
   100  				},
   101  			},
   102  			{
   103  				overloadId: 6,
   104  				args:       []types.T{types.T_int64},
   105  				retType: func(parameters []types.Type) types.Type {
   106  					return types.T_uint8.ToType()
   107  				},
   108  				newOp: func() executeLogicOfOverload {
   109  					return AsciiInt[int64]
   110  				},
   111  			},
   112  			{
   113  				overloadId: 7,
   114  				args:       []types.T{types.T_uint8},
   115  				retType: func(parameters []types.Type) types.Type {
   116  					return types.T_uint8.ToType()
   117  				},
   118  				newOp: func() executeLogicOfOverload {
   119  					return AsciiUint[uint8]
   120  				},
   121  			},
   122  			{
   123  				overloadId: 8,
   124  				args:       []types.T{types.T_uint16},
   125  				retType: func(parameters []types.Type) types.Type {
   126  					return types.T_uint8.ToType()
   127  				},
   128  				newOp: func() executeLogicOfOverload {
   129  					return AsciiUint[uint16]
   130  				},
   131  			},
   132  			{
   133  				overloadId: 9,
   134  				args:       []types.T{types.T_uint32},
   135  				retType: func(parameters []types.Type) types.Type {
   136  					return types.T_uint8.ToType()
   137  				},
   138  				newOp: func() executeLogicOfOverload {
   139  					return AsciiUint[uint32]
   140  				},
   141  			},
   142  			{
   143  				overloadId: 10,
   144  				args:       []types.T{types.T_uint64},
   145  				retType: func(parameters []types.Type) types.Type {
   146  					return types.T_uint8.ToType()
   147  				},
   148  				newOp: func() executeLogicOfOverload {
   149  					return AsciiUint[uint64]
   150  				},
   151  			},
   152  		},
   153  	},
   154  
   155  	// function `binary`
   156  	{
   157  		functionId: BINARY,
   158  		class:      plan.Function_STRICT,
   159  		layout:     CAST_EXPRESSION,
   160  		checkFn:    fixedTypeMatch,
   161  
   162  		Overloads: []overload{
   163  			{
   164  				overloadId: 0,
   165  				args:       []types.T{types.T_varchar},
   166  				retType: func(parameters []types.Type) types.Type {
   167  					return types.T_binary.ToType()
   168  				},
   169  				newOp: func() executeLogicOfOverload {
   170  					return Binary
   171  				},
   172  			},
   173  		},
   174  	},
   175  
   176  	// function `bit_length`
   177  	{
   178  		functionId: BIT_LENGTH,
   179  		class:      plan.Function_STRICT,
   180  		layout:     STANDARD_FUNCTION,
   181  		checkFn:    fixedTypeMatch,
   182  
   183  		Overloads: []overload{
   184  			{
   185  				overloadId: 0,
   186  				args:       []types.T{types.T_varchar}, // old is t_char, I think t_varchar is more suitable.
   187  				retType: func(parameters []types.Type) types.Type {
   188  					return types.T_int64.ToType()
   189  				},
   190  				newOp: func() executeLogicOfOverload {
   191  					return BitLengthFunc
   192  				},
   193  			},
   194  		},
   195  	},
   196  
   197  	// function `concat`
   198  	{
   199  		functionId: CONCAT,
   200  		class:      plan.Function_STRICT,
   201  		layout:     STANDARD_FUNCTION,
   202  		checkFn:    builtInConcatCheck,
   203  
   204  		Overloads: []overload{
   205  			{
   206  				overloadId: 0,
   207  				retType: func(parameters []types.Type) types.Type {
   208  					for _, p := range parameters {
   209  						if p.Oid == types.T_binary || p.Oid == types.T_varbinary || p.Oid == types.T_blob {
   210  							return types.T_blob.ToType()
   211  						}
   212  					}
   213  					return types.T_varchar.ToType()
   214  				},
   215  				newOp: func() executeLogicOfOverload {
   216  					return builtInConcat
   217  				},
   218  			},
   219  		},
   220  	},
   221  
   222  	// function `concat_ws`
   223  	{
   224  		functionId: CONCAT_WS,
   225  		class:      plan.Function_STRICT,
   226  		layout:     STANDARD_FUNCTION,
   227  		checkFn:    concatWsCheck,
   228  
   229  		Overloads: []overload{
   230  			{
   231  				overloadId: 0,
   232  				args:       []types.T{},
   233  				retType: func(parameters []types.Type) types.Type {
   234  					for _, p := range parameters {
   235  						if p.Oid == types.T_binary || p.Oid == types.T_varbinary || p.Oid == types.T_blob {
   236  							return types.T_blob.ToType()
   237  						}
   238  					}
   239  					return types.T_varchar.ToType()
   240  				},
   241  				newOp: func() executeLogicOfOverload {
   242  					return ConcatWs
   243  				},
   244  			},
   245  		},
   246  	},
   247  
   248  	// function `convert`
   249  	{
   250  		functionId: CONVERT,
   251  		class:      plan.Function_STRICT,
   252  		layout:     STANDARD_FUNCTION,
   253  		checkFn:    fixedTypeMatch,
   254  
   255  		Overloads: []overload{
   256  			{
   257  				overloadId:      0,
   258  				args:            []types.T{types.T_varchar, types.T_varchar},
   259  				volatile:        true,
   260  				realTimeRelated: true,
   261  				retType: func(parameters []types.Type) types.Type {
   262  					return types.T_varchar.ToType()
   263  				},
   264  				newOp: func() executeLogicOfOverload {
   265  					return builtInConvertFake
   266  				},
   267  			},
   268  		},
   269  	},
   270  
   271  	// function `empty`
   272  	{
   273  		functionId: EMPTY,
   274  		class:      plan.Function_STRICT,
   275  		layout:     STANDARD_FUNCTION,
   276  		checkFn:    fixedTypeMatch,
   277  
   278  		Overloads: []overload{
   279  			{
   280  				overloadId: 0,
   281  				args:       []types.T{types.T_char},
   282  				retType: func(parameters []types.Type) types.Type {
   283  					return types.T_bool.ToType()
   284  				},
   285  				newOp: func() executeLogicOfOverload {
   286  					return Empty
   287  				},
   288  			},
   289  		},
   290  	},
   291  
   292  	// function `endswith`
   293  	{
   294  		functionId: ENDSWITH,
   295  		class:      plan.Function_STRICT,
   296  		layout:     STANDARD_FUNCTION,
   297  		checkFn:    fixedTypeMatch,
   298  
   299  		Overloads: []overload{
   300  			{
   301  				overloadId: 0,
   302  				args:       []types.T{types.T_varchar, types.T_varchar},
   303  				retType: func(parameters []types.Type) types.Type {
   304  					return types.T_bool.ToType()
   305  				},
   306  				newOp: func() executeLogicOfOverload {
   307  					return EndsWith
   308  				},
   309  			},
   310  		},
   311  	},
   312  
   313  	// function `extract`
   314  	{
   315  		functionId: EXTRACT,
   316  		class:      plan.Function_STRICT,
   317  		layout:     STANDARD_FUNCTION,
   318  		checkFn:    fixedTypeMatch,
   319  
   320  		Overloads: []overload{
   321  			{
   322  				overloadId: 0,
   323  				args:       []types.T{types.T_varchar, types.T_datetime},
   324  				retType: func(parameters []types.Type) types.Type {
   325  					return types.T_varchar.ToType()
   326  				},
   327  				newOp: func() executeLogicOfOverload {
   328  					return ExtractFromDatetime
   329  				},
   330  			},
   331  			{
   332  				overloadId: 1,
   333  				args:       []types.T{types.T_varchar, types.T_date},
   334  				retType: func(parameters []types.Type) types.Type {
   335  					return types.T_uint32.ToType()
   336  				},
   337  				newOp: func() executeLogicOfOverload {
   338  					return ExtractFromDate
   339  				},
   340  			},
   341  			{
   342  				overloadId: 2,
   343  				args:       []types.T{types.T_varchar, types.T_time},
   344  				retType: func(parameters []types.Type) types.Type {
   345  					return types.T_varchar.ToType()
   346  				},
   347  				newOp: func() executeLogicOfOverload {
   348  					return ExtractFromTime
   349  				},
   350  			},
   351  			{
   352  				overloadId: 3,
   353  				args:       []types.T{types.T_varchar, types.T_varchar},
   354  				retType: func(parameters []types.Type) types.Type {
   355  					return types.T_varchar.ToType()
   356  				},
   357  				newOp: func() executeLogicOfOverload {
   358  					return ExtractFromVarchar
   359  				},
   360  			},
   361  		},
   362  	},
   363  
   364  	// function `field`
   365  	{
   366  		functionId: FIELD,
   367  		class:      plan.Function_STRICT,
   368  		layout:     STANDARD_FUNCTION,
   369  		checkFn:    fieldCheck,
   370  
   371  		Overloads: []overload{
   372  			{
   373  				overloadId: 0,
   374  				args:       []types.T{types.T_varchar, types.T_char},
   375  				retType: func(parameters []types.Type) types.Type {
   376  					return types.T_uint64.ToType()
   377  				},
   378  				newOp: func() executeLogicOfOverload {
   379  					return FieldString
   380  				},
   381  			},
   382  			{
   383  				overloadId: 1,
   384  				args:       []types.T{types.T_int8},
   385  				retType: func(parameters []types.Type) types.Type {
   386  					return types.T_uint64.ToType()
   387  				},
   388  				newOp: func() executeLogicOfOverload {
   389  					return FieldNumber[int8]
   390  				},
   391  			},
   392  			{
   393  				overloadId: 2,
   394  				args:       []types.T{types.T_int16},
   395  				retType: func(parameters []types.Type) types.Type {
   396  					return types.T_uint64.ToType()
   397  				},
   398  				newOp: func() executeLogicOfOverload {
   399  					return FieldNumber[int16]
   400  				},
   401  			},
   402  			{
   403  				overloadId: 3,
   404  				args:       []types.T{types.T_int32},
   405  				retType: func(parameters []types.Type) types.Type {
   406  					return types.T_uint64.ToType()
   407  				},
   408  				newOp: func() executeLogicOfOverload {
   409  					return FieldNumber[int32]
   410  				},
   411  			},
   412  			{
   413  				overloadId: 4,
   414  				args:       []types.T{types.T_int64},
   415  				retType: func(parameters []types.Type) types.Type {
   416  					return types.T_uint64.ToType()
   417  				},
   418  				newOp: func() executeLogicOfOverload {
   419  					return FieldNumber[int64]
   420  				},
   421  			},
   422  			{
   423  				overloadId: 5,
   424  				args:       []types.T{types.T_uint8},
   425  				retType: func(parameters []types.Type) types.Type {
   426  					return types.T_uint64.ToType()
   427  				},
   428  				newOp: func() executeLogicOfOverload {
   429  					return FieldNumber[uint8]
   430  				},
   431  			},
   432  			{
   433  				overloadId: 6,
   434  				args:       []types.T{types.T_uint16},
   435  				retType: func(parameters []types.Type) types.Type {
   436  					return types.T_uint64.ToType()
   437  				},
   438  				newOp: func() executeLogicOfOverload {
   439  					return FieldNumber[uint16]
   440  				},
   441  			},
   442  			{
   443  				overloadId: 7,
   444  				args:       []types.T{types.T_uint32},
   445  				retType: func(parameters []types.Type) types.Type {
   446  					return types.T_uint64.ToType()
   447  				},
   448  				newOp: func() executeLogicOfOverload {
   449  					return FieldNumber[uint32]
   450  				},
   451  			},
   452  			{
   453  				overloadId: 8,
   454  				args:       []types.T{types.T_uint64},
   455  				retType: func(parameters []types.Type) types.Type {
   456  					return types.T_uint64.ToType()
   457  				},
   458  				newOp: func() executeLogicOfOverload {
   459  					return FieldNumber[uint64]
   460  				},
   461  			},
   462  			{
   463  				overloadId: 9,
   464  				args:       []types.T{types.T_float32},
   465  				retType: func(parameters []types.Type) types.Type {
   466  					return types.T_uint64.ToType()
   467  				},
   468  				newOp: func() executeLogicOfOverload {
   469  					return FieldNumber[float32]
   470  				},
   471  			},
   472  			{
   473  				overloadId: 10,
   474  				args:       []types.T{types.T_float64},
   475  				retType: func(parameters []types.Type) types.Type {
   476  					return types.T_uint64.ToType()
   477  				},
   478  				newOp: func() executeLogicOfOverload {
   479  					return FieldNumber[float64]
   480  				},
   481  			},
   482  		},
   483  	},
   484  
   485  	// function `findinset`, `find_in_set`
   486  	{
   487  		functionId: FINDINSET,
   488  		class:      plan.Function_STRICT,
   489  		layout:     STANDARD_FUNCTION,
   490  		checkFn:    fixedTypeMatch,
   491  
   492  		Overloads: []overload{
   493  			{
   494  				overloadId: 0,
   495  				args:       []types.T{types.T_varchar, types.T_varchar},
   496  				retType: func(parameters []types.Type) types.Type {
   497  					return types.T_uint64.ToType()
   498  				},
   499  				newOp: func() executeLogicOfOverload {
   500  					return FindInSet
   501  				},
   502  			},
   503  		},
   504  	},
   505  
   506  	// function `format`
   507  	{
   508  		functionId: FORMAT,
   509  		class:      plan.Function_STRICT,
   510  		layout:     STANDARD_FUNCTION,
   511  		checkFn:    formatCheck,
   512  
   513  		Overloads: []overload{
   514  			{
   515  				overloadId: 0,
   516  				args:       []types.T{types.T_varchar, types.T_varchar},
   517  				retType: func(parameters []types.Type) types.Type {
   518  					return types.T_varchar.ToType()
   519  				},
   520  				newOp: func() executeLogicOfOverload {
   521  					return FormatWith2Args
   522  				},
   523  			},
   524  			{
   525  				overloadId: 1,
   526  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_varchar},
   527  				retType: func(parameters []types.Type) types.Type {
   528  					return types.T_varchar.ToType()
   529  				},
   530  				newOp: func() executeLogicOfOverload {
   531  					return FormatWith3Args
   532  				},
   533  			},
   534  		},
   535  	},
   536  
   537  	// function `ilike`
   538  	{
   539  		functionId: ILIKE,
   540  		class:      plan.Function_STRICT,
   541  		layout:     BINARY_LOGICAL_OPERATOR,
   542  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
   543  			if len(inputs) == 2 {
   544  				if inputs[0].Oid.IsMySQLString() && inputs[1].Oid.IsMySQLString() {
   545  					return newCheckResultWithSuccess(0)
   546  				}
   547  			}
   548  			return newCheckResultWithFailure(failedFunctionParametersWrong)
   549  		},
   550  
   551  		Overloads: []overload{
   552  			{
   553  				overloadId: 0,
   554  				retType: func(parameters []types.Type) types.Type {
   555  					return types.T_bool.ToType()
   556  				},
   557  				newOp: func() executeLogicOfOverload {
   558  					return newOpBuiltInRegexp().iLikeFn
   559  				},
   560  			},
   561  		},
   562  	},
   563  
   564  	// function `instr`
   565  	{
   566  		functionId: INSTR,
   567  		class:      plan.Function_STRICT,
   568  		layout:     STANDARD_FUNCTION,
   569  		checkFn:    fixedTypeMatch,
   570  
   571  		Overloads: []overload{
   572  			{
   573  				overloadId: 0,
   574  				args:       []types.T{types.T_varchar, types.T_varchar},
   575  				retType: func(parameters []types.Type) types.Type {
   576  					return types.T_int64.ToType()
   577  				},
   578  				newOp: func() executeLogicOfOverload {
   579  					return Instr
   580  				},
   581  			},
   582  		},
   583  	},
   584  
   585  	// function `json_extract`
   586  	{
   587  		functionId: JSON_EXTRACT,
   588  		class:      plan.Function_STRICT,
   589  		layout:     STANDARD_FUNCTION,
   590  		checkFn:    jsonExtractCheckFn,
   591  		Overloads: []overload{
   592  			{
   593  				overloadId: 0,
   594  				args:       []types.T{},
   595  				retType: func(parameters []types.Type) types.Type {
   596  					return types.T_json.ToType()
   597  				},
   598  				newOp: func() executeLogicOfOverload {
   599  					return JsonExtract
   600  				},
   601  			},
   602  		},
   603  	},
   604  
   605  	// function `json_quote`
   606  	{
   607  		functionId: JSON_QUOTE,
   608  		class:      plan.Function_STRICT,
   609  		layout:     STANDARD_FUNCTION,
   610  		checkFn:    fixedTypeMatch,
   611  
   612  		Overloads: []overload{
   613  			{
   614  				overloadId: 0,
   615  				args:       []types.T{types.T_varchar},
   616  				retType: func(parameters []types.Type) types.Type {
   617  					return types.T_json.ToType()
   618  				},
   619  				newOp: func() executeLogicOfOverload {
   620  					return JsonQuote
   621  				},
   622  			},
   623  		},
   624  	},
   625  
   626  	// function `json_unquote`
   627  	{
   628  		functionId: JSON_UNQUOTE,
   629  		class:      plan.Function_STRICT,
   630  		layout:     STANDARD_FUNCTION,
   631  		checkFn:    fixedTypeMatch,
   632  
   633  		Overloads: []overload{
   634  			{
   635  				overloadId: 0,
   636  				args:       []types.T{types.T_json},
   637  				retType: func(parameters []types.Type) types.Type {
   638  					return types.T_varchar.ToType()
   639  				},
   640  				newOp: func() executeLogicOfOverload {
   641  					return JsonUnquote
   642  				},
   643  			},
   644  			{
   645  				overloadId: 1,
   646  				args:       []types.T{types.T_varchar},
   647  				retType: func(parameters []types.Type) types.Type {
   648  					return types.T_varchar.ToType()
   649  				},
   650  				newOp: func() executeLogicOfOverload {
   651  					return JsonUnquote
   652  				},
   653  			},
   654  			{
   655  				overloadId: 2,
   656  				args:       []types.T{types.T_char},
   657  				retType: func(parameters []types.Type) types.Type {
   658  					return types.T_varchar.ToType()
   659  				},
   660  				newOp: func() executeLogicOfOverload {
   661  					return JsonUnquote
   662  				},
   663  			},
   664  			{
   665  				overloadId: 3,
   666  				args:       []types.T{types.T_text},
   667  				retType: func(parameters []types.Type) types.Type {
   668  					return types.T_varchar.ToType()
   669  				},
   670  				newOp: func() executeLogicOfOverload {
   671  					return JsonUnquote
   672  				},
   673  			},
   674  		},
   675  	},
   676  
   677  	// function `left`
   678  	{
   679  		functionId: LEFT,
   680  		class:      plan.Function_STRICT,
   681  		layout:     STANDARD_FUNCTION,
   682  		checkFn:    fixedTypeMatch,
   683  
   684  		Overloads: []overload{
   685  			{
   686  				overloadId: 0,
   687  				args:       []types.T{types.T_varchar, types.T_int64},
   688  				retType: func(parameters []types.Type) types.Type {
   689  					return types.T_varchar.ToType()
   690  				},
   691  				newOp: func() executeLogicOfOverload {
   692  					return Left
   693  				},
   694  			},
   695  			{
   696  				overloadId: 1,
   697  				args:       []types.T{types.T_char, types.T_int64},
   698  				retType: func(parameters []types.Type) types.Type {
   699  					return types.T_char.ToType()
   700  				},
   701  				newOp: func() executeLogicOfOverload {
   702  					return Left
   703  				},
   704  			},
   705  		},
   706  	},
   707  
   708  	// function `length`
   709  	{
   710  		functionId: LENGTH,
   711  		class:      plan.Function_STRICT,
   712  		layout:     STANDARD_FUNCTION,
   713  		checkFn:    fixedTypeMatch,
   714  
   715  		Overloads: []overload{
   716  			{
   717  				overloadId: 0,
   718  				args:       []types.T{types.T_varchar},
   719  				retType: func(parameters []types.Type) types.Type {
   720  					return types.T_int64.ToType()
   721  				},
   722  				newOp: func() executeLogicOfOverload {
   723  					return Length
   724  				},
   725  			},
   726  			{
   727  				overloadId: 1,
   728  				args:       []types.T{types.T_char},
   729  				retType: func(parameters []types.Type) types.Type {
   730  					return types.T_int64.ToType()
   731  				},
   732  				newOp: func() executeLogicOfOverload {
   733  					return Length
   734  				},
   735  			},
   736  			{
   737  				overloadId: 2,
   738  				args:       []types.T{types.T_text},
   739  				retType: func(parameters []types.Type) types.Type {
   740  					return types.T_int64.ToType()
   741  				},
   742  				newOp: func() executeLogicOfOverload {
   743  					return Length
   744  				},
   745  			},
   746  			{
   747  				overloadId: 3,
   748  				args:       []types.T{types.T_blob},
   749  				retType: func(parameters []types.Type) types.Type {
   750  					return types.T_int64.ToType()
   751  				},
   752  				newOp: func() executeLogicOfOverload {
   753  					return Length
   754  				},
   755  			},
   756  		},
   757  	},
   758  
   759  	// function `length_utf8`, `char_length`
   760  	{
   761  		functionId: LENGTH_UTF8,
   762  		class:      plan.Function_STRICT,
   763  		layout:     STANDARD_FUNCTION,
   764  		checkFn:    fixedTypeMatch,
   765  
   766  		Overloads: []overload{
   767  			{
   768  				overloadId: 0,
   769  				args:       []types.T{types.T_varchar},
   770  				retType: func(parameters []types.Type) types.Type {
   771  					return types.T_uint64.ToType()
   772  				},
   773  				newOp: func() executeLogicOfOverload {
   774  					return LengthUTF8
   775  				},
   776  			},
   777  			{
   778  				overloadId: 1,
   779  				args:       []types.T{types.T_char},
   780  				retType: func(parameters []types.Type) types.Type {
   781  					return types.T_uint64.ToType()
   782  				},
   783  				newOp: func() executeLogicOfOverload {
   784  					return LengthUTF8
   785  				},
   786  			},
   787  		},
   788  	},
   789  
   790  	// function `lpad`
   791  	{
   792  		functionId: LPAD,
   793  		class:      plan.Function_STRICT,
   794  		layout:     STANDARD_FUNCTION,
   795  		checkFn:    fixedTypeMatch,
   796  
   797  		Overloads: []overload{
   798  			{
   799  				overloadId: 0,
   800  				args:       []types.T{types.T_varchar, types.T_int64, types.T_varchar},
   801  				retType: func(parameters []types.Type) types.Type {
   802  					return types.T_varchar.ToType()
   803  				},
   804  				newOp: func() executeLogicOfOverload {
   805  					return builtInLpad
   806  				},
   807  			},
   808  			{
   809  				overloadId: 1,
   810  				args:       []types.T{types.T_blob, types.T_int64, types.T_blob},
   811  				retType: func(parameters []types.Type) types.Type {
   812  					return types.T_blob.ToType()
   813  				},
   814  				newOp: func() executeLogicOfOverload {
   815  					return builtInLpad
   816  				},
   817  			},
   818  			{
   819  				overloadId: 2,
   820  				args:       []types.T{types.T_blob, types.T_int64, types.T_varchar},
   821  				retType: func(parameters []types.Type) types.Type {
   822  					return types.T_blob.ToType()
   823  				},
   824  				newOp: func() executeLogicOfOverload {
   825  					return builtInLpad
   826  				},
   827  			},
   828  		},
   829  	},
   830  
   831  	// function `ltrim`
   832  	{
   833  		functionId: LTRIM,
   834  		class:      plan.Function_STRICT,
   835  		layout:     STANDARD_FUNCTION,
   836  		checkFn:    fixedTypeMatch,
   837  
   838  		Overloads: []overload{
   839  			{
   840  				overloadId: 0,
   841  				args:       []types.T{types.T_char},
   842  				retType: func(parameters []types.Type) types.Type {
   843  					return types.T_varchar.ToType()
   844  				},
   845  				newOp: func() executeLogicOfOverload {
   846  					return Ltrim
   847  				},
   848  			},
   849  			{
   850  				overloadId: 0,
   851  				args:       []types.T{types.T_blob},
   852  				retType: func(parameter []types.Type) types.Type {
   853  					return types.T_blob.ToType()
   854  				},
   855  				newOp: func() executeLogicOfOverload {
   856  					return Ltrim
   857  				},
   858  			},
   859  		},
   860  	},
   861  
   862  	// function `not_reg_match`
   863  	{
   864  		functionId: NOT_REG_MATCH,
   865  		class:      plan.Function_STRICT,
   866  		layout:     COMPARISON_OPERATOR,
   867  		checkFn:    fixedTypeMatch,
   868  
   869  		Overloads: []overload{
   870  			{
   871  				overloadId: 0,
   872  				args:       []types.T{types.T_varchar, types.T_varchar},
   873  				retType: func(parameters []types.Type) types.Type {
   874  					return types.T_bool.ToType()
   875  				},
   876  				newOp: func() executeLogicOfOverload {
   877  					return newOpBuiltInRegexp().builtInNotRegMatch
   878  				},
   879  			},
   880  		},
   881  	},
   882  
   883  	// function `replace`
   884  	{
   885  		functionId: REPLACE,
   886  		class:      plan.Function_STRICT,
   887  		layout:     STANDARD_FUNCTION,
   888  		checkFn:    fixedTypeMatch,
   889  
   890  		Overloads: []overload{
   891  			{
   892  				overloadId: 0,
   893  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_varchar},
   894  				retType: func(parameters []types.Type) types.Type {
   895  					return types.T_varchar.ToType()
   896  				},
   897  				newOp: func() executeLogicOfOverload {
   898  					return Replace
   899  				},
   900  			},
   901  		},
   902  	},
   903  
   904  	// function `reg_match`
   905  	{
   906  		functionId: REG_MATCH,
   907  		class:      plan.Function_STRICT,
   908  		layout:     COMPARISON_OPERATOR,
   909  		checkFn:    fixedTypeMatch,
   910  
   911  		Overloads: []overload{
   912  			{
   913  				overloadId: 0,
   914  				args:       []types.T{types.T_varchar, types.T_varchar},
   915  				retType: func(parameters []types.Type) types.Type {
   916  					return types.T_bool.ToType()
   917  				},
   918  				newOp: func() executeLogicOfOverload {
   919  					return newOpBuiltInRegexp().builtInRegMatch
   920  				},
   921  			},
   922  		},
   923  	},
   924  
   925  	// function `regexp_instr`
   926  	{
   927  		functionId: REGEXP_INSTR,
   928  		class:      plan.Function_STRICT,
   929  		layout:     STANDARD_FUNCTION,
   930  		checkFn:    fixedTypeMatch,
   931  
   932  		Overloads: []overload{
   933  			{
   934  				overloadId: 0,
   935  				args:       []types.T{types.T_varchar, types.T_varchar},
   936  				retType: func(parameters []types.Type) types.Type {
   937  					return types.T_int64.ToType()
   938  				},
   939  				newOp: func() executeLogicOfOverload {
   940  					return newOpBuiltInRegexp().builtInRegexpInstr
   941  				},
   942  			},
   943  			{
   944  				overloadId: 1,
   945  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_int64},
   946  				retType: func(parameters []types.Type) types.Type {
   947  					return types.T_int64.ToType()
   948  				},
   949  				newOp: func() executeLogicOfOverload {
   950  					return newOpBuiltInRegexp().builtInRegexpInstr
   951  				},
   952  			},
   953  			{
   954  				overloadId: 2,
   955  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_int64, types.T_int64},
   956  				retType: func(parameters []types.Type) types.Type {
   957  					return types.T_int64.ToType()
   958  				},
   959  				newOp: func() executeLogicOfOverload {
   960  					return newOpBuiltInRegexp().builtInRegexpInstr
   961  				},
   962  			},
   963  			{
   964  				overloadId: 3,
   965  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_int64, types.T_int64, types.T_int8},
   966  				retType: func(parameters []types.Type) types.Type {
   967  					return types.T_int64.ToType()
   968  				},
   969  				newOp: func() executeLogicOfOverload {
   970  					return newOpBuiltInRegexp().builtInRegexpInstr
   971  				},
   972  			},
   973  		},
   974  	},
   975  
   976  	// function `regexp_like`
   977  	{
   978  		functionId: REGEXP_LIKE,
   979  		class:      plan.Function_STRICT,
   980  		layout:     STANDARD_FUNCTION,
   981  		checkFn:    fixedTypeMatch,
   982  
   983  		Overloads: []overload{
   984  			{
   985  				overloadId: 0,
   986  				args:       []types.T{types.T_varchar, types.T_varchar},
   987  				retType: func(parameters []types.Type) types.Type {
   988  					return types.T_bool.ToType()
   989  				},
   990  				newOp: func() executeLogicOfOverload {
   991  					return newOpBuiltInRegexp().builtInRegexpLike
   992  				},
   993  			},
   994  			{
   995  				overloadId: 1,
   996  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_varchar},
   997  				retType: func(parameters []types.Type) types.Type {
   998  					return types.T_bool.ToType()
   999  				},
  1000  				newOp: func() executeLogicOfOverload {
  1001  					return newOpBuiltInRegexp().builtInRegexpLike
  1002  				},
  1003  			},
  1004  		},
  1005  	},
  1006  
  1007  	// function `regexp_replace`
  1008  	{
  1009  		functionId: REGEXP_REPLACE,
  1010  		class:      plan.Function_STRICT,
  1011  		layout:     STANDARD_FUNCTION,
  1012  		checkFn:    fixedTypeMatch,
  1013  
  1014  		Overloads: []overload{
  1015  			{
  1016  				overloadId: 0,
  1017  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_varchar},
  1018  				retType: func(parameters []types.Type) types.Type {
  1019  					return types.T_varchar.ToType()
  1020  				},
  1021  				newOp: func() executeLogicOfOverload {
  1022  					return newOpBuiltInRegexp().builtInRegexpReplace
  1023  				},
  1024  			},
  1025  			{
  1026  				overloadId: 1,
  1027  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_varchar, types.T_int64},
  1028  				retType: func(parameters []types.Type) types.Type {
  1029  					return types.T_varchar.ToType()
  1030  				},
  1031  				newOp: func() executeLogicOfOverload {
  1032  					return newOpBuiltInRegexp().builtInRegexpReplace
  1033  				},
  1034  			},
  1035  			{
  1036  				overloadId: 2,
  1037  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_varchar, types.T_int64, types.T_int64},
  1038  				retType: func(parameters []types.Type) types.Type {
  1039  					return types.T_varchar.ToType()
  1040  				},
  1041  				newOp: func() executeLogicOfOverload {
  1042  					return newOpBuiltInRegexp().builtInRegexpReplace
  1043  				},
  1044  			},
  1045  		},
  1046  	},
  1047  
  1048  	// function `regexp_substr`
  1049  	{
  1050  		functionId: REGEXP_SUBSTR,
  1051  		class:      plan.Function_STRICT,
  1052  		layout:     STANDARD_FUNCTION,
  1053  		checkFn:    fixedTypeMatch,
  1054  
  1055  		Overloads: []overload{
  1056  			{
  1057  				overloadId: 0,
  1058  				args:       []types.T{types.T_varchar, types.T_varchar},
  1059  				retType: func(parameters []types.Type) types.Type {
  1060  					return types.T_varchar.ToType()
  1061  				},
  1062  				newOp: func() executeLogicOfOverload {
  1063  					return newOpBuiltInRegexp().builtInRegexpSubstr
  1064  				},
  1065  			},
  1066  
  1067  			{
  1068  				overloadId: 1,
  1069  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_int64},
  1070  				retType: func(parameters []types.Type) types.Type {
  1071  					return types.T_varchar.ToType()
  1072  				},
  1073  				newOp: func() executeLogicOfOverload {
  1074  					return newOpBuiltInRegexp().builtInRegexpSubstr
  1075  				},
  1076  			},
  1077  
  1078  			{
  1079  				overloadId: 2,
  1080  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_int64, types.T_int64},
  1081  				retType: func(parameters []types.Type) types.Type {
  1082  					return types.T_varchar.ToType()
  1083  				},
  1084  				newOp: func() executeLogicOfOverload {
  1085  					return newOpBuiltInRegexp().builtInRegexpSubstr
  1086  				},
  1087  			},
  1088  		},
  1089  	},
  1090  
  1091  	// function `repeat`
  1092  	{
  1093  		functionId: REPEAT,
  1094  		class:      plan.Function_STRICT,
  1095  		layout:     STANDARD_FUNCTION,
  1096  		checkFn:    fixedTypeMatch,
  1097  
  1098  		Overloads: []overload{
  1099  			{
  1100  				overloadId: 0,
  1101  				args:       []types.T{types.T_varchar, types.T_int64},
  1102  				retType: func(parameters []types.Type) types.Type {
  1103  					return types.T_varchar.ToType()
  1104  				},
  1105  				newOp: func() executeLogicOfOverload {
  1106  					return builtInRepeat
  1107  				},
  1108  			},
  1109  		},
  1110  	},
  1111  
  1112  	// function `reverse`
  1113  	{
  1114  		functionId: REVERSE,
  1115  		class:      plan.Function_STRICT,
  1116  		layout:     STANDARD_FUNCTION,
  1117  		checkFn:    fixedTypeMatch,
  1118  
  1119  		Overloads: []overload{
  1120  			{
  1121  				overloadId: 0,
  1122  				args:       []types.T{types.T_char},
  1123  				retType: func(parameters []types.Type) types.Type {
  1124  					return types.T_varchar.ToType()
  1125  				},
  1126  				newOp: func() executeLogicOfOverload {
  1127  					return Reverse
  1128  				},
  1129  			},
  1130  			{
  1131  				overloadId: 1,
  1132  				args:       []types.T{types.T_varchar},
  1133  				retType: func(parameters []types.Type) types.Type {
  1134  					return types.T_varchar.ToType()
  1135  				},
  1136  				newOp: func() executeLogicOfOverload {
  1137  					return Reverse
  1138  				},
  1139  			},
  1140  			{
  1141  				overloadId: 2,
  1142  				args:       []types.T{types.T_blob},
  1143  				retType: func(parameter []types.Type) types.Type {
  1144  					return types.T_blob.ToType()
  1145  				},
  1146  				newOp: func() executeLogicOfOverload {
  1147  					return Reverse
  1148  				},
  1149  			},
  1150  		},
  1151  	},
  1152  
  1153  	// function `rpad`
  1154  	{
  1155  		functionId: RPAD,
  1156  		class:      plan.Function_STRICT,
  1157  		layout:     STANDARD_FUNCTION,
  1158  		checkFn:    fixedTypeMatch,
  1159  
  1160  		Overloads: []overload{
  1161  			{
  1162  				overloadId: 0,
  1163  				args:       []types.T{types.T_varchar, types.T_int64, types.T_varchar},
  1164  				retType: func(parameters []types.Type) types.Type {
  1165  					return types.T_varchar.ToType()
  1166  				},
  1167  				newOp: func() executeLogicOfOverload {
  1168  					return builtInRpad
  1169  				},
  1170  			},
  1171  			{
  1172  				overloadId: 1,
  1173  				args:       []types.T{types.T_blob, types.T_int64, types.T_blob},
  1174  				retType: func(parameters []types.Type) types.Type {
  1175  					return types.T_blob.ToType()
  1176  				},
  1177  				newOp: func() executeLogicOfOverload {
  1178  					return builtInRpad
  1179  				},
  1180  			},
  1181  			{
  1182  				overloadId: 2,
  1183  				args:       []types.T{types.T_blob, types.T_int64, types.T_varchar},
  1184  				retType: func(parameters []types.Type) types.Type {
  1185  					return types.T_blob.ToType()
  1186  				},
  1187  				newOp: func() executeLogicOfOverload {
  1188  					return builtInRpad
  1189  				},
  1190  			},
  1191  		},
  1192  	},
  1193  
  1194  	// function `rtrim`
  1195  	{
  1196  		functionId: RTRIM,
  1197  		class:      plan.Function_STRICT,
  1198  		layout:     STANDARD_FUNCTION,
  1199  		checkFn:    fixedTypeMatch,
  1200  
  1201  		Overloads: []overload{
  1202  			{
  1203  				overloadId: 0,
  1204  				args:       []types.T{types.T_char},
  1205  				retType: func(parameters []types.Type) types.Type {
  1206  					return types.T_varchar.ToType()
  1207  				},
  1208  				newOp: func() executeLogicOfOverload {
  1209  					return Rtrim
  1210  				},
  1211  			},
  1212  			{
  1213  				overloadId: 0,
  1214  				args:       []types.T{types.T_blob},
  1215  				retType: func(parameter []types.Type) types.Type {
  1216  					return types.T_blob.ToType()
  1217  				},
  1218  				newOp: func() executeLogicOfOverload {
  1219  					return Rtrim
  1220  				},
  1221  			},
  1222  		},
  1223  	},
  1224  
  1225  	// function `serial`
  1226  	{
  1227  		functionId: SERIAL,
  1228  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  1229  		layout:     STANDARD_FUNCTION,
  1230  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
  1231  			if len(inputs) > 0 {
  1232  				return newCheckResultWithSuccess(0)
  1233  			}
  1234  			return newCheckResultWithFailure(failedFunctionParametersWrong)
  1235  		},
  1236  
  1237  		Overloads: []overload{
  1238  			{
  1239  				overloadId: 0,
  1240  				retType: func(parameters []types.Type) types.Type {
  1241  					return types.T_varchar.ToType()
  1242  				},
  1243  				newOpWithFree: func() (executeLogicOfOverload, executeFreeOfOverload) {
  1244  					opSerial := newOpSerial()
  1245  					return opSerial.BuiltInSerial, opSerial.Close
  1246  				},
  1247  			},
  1248  		},
  1249  	},
  1250  
  1251  	// function `serial_full`
  1252  	{
  1253  		functionId: SERIAL_FULL,
  1254  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  1255  		layout:     STANDARD_FUNCTION,
  1256  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
  1257  			if len(inputs) > 0 {
  1258  				return newCheckResultWithSuccess(0)
  1259  			}
  1260  			return newCheckResultWithFailure(failedFunctionParametersWrong)
  1261  		},
  1262  
  1263  		Overloads: []overload{
  1264  			{
  1265  				overloadId: 0,
  1266  				retType: func(parameters []types.Type) types.Type {
  1267  					return types.T_varchar.ToType()
  1268  				},
  1269  				newOpWithFree: func() (executeLogicOfOverload, executeFreeOfOverload) {
  1270  					opSerial := newOpSerial()
  1271  					return opSerial.BuiltInSerialFull, opSerial.Close
  1272  				},
  1273  			},
  1274  		},
  1275  	},
  1276  
  1277  	// function `serial_extract`
  1278  	{
  1279  		functionId: SERIAL_EXTRACT,
  1280  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  1281  		layout:     STANDARD_FUNCTION,
  1282  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
  1283  			if len(inputs) == 3 {
  1284  				if inputs[0].Oid == types.T_varchar &&
  1285  					inputs[1].Oid == types.T_int64 {
  1286  					return newCheckResultWithSuccess(0)
  1287  				}
  1288  			}
  1289  			return newCheckResultWithFailure(failedFunctionParametersWrong)
  1290  		},
  1291  		Overloads: []overload{
  1292  			{
  1293  				overloadId: 0,
  1294  				retType: func(parameters []types.Type) types.Type {
  1295  					return parameters[2]
  1296  				},
  1297  				newOp: func() executeLogicOfOverload {
  1298  					return builtInSerialExtract
  1299  				},
  1300  			},
  1301  		},
  1302  	},
  1303  
  1304  	// function `space`
  1305  	{
  1306  		functionId: SPACE,
  1307  		class:      plan.Function_STRICT,
  1308  		layout:     STANDARD_FUNCTION,
  1309  		checkFn:    fixedTypeMatch,
  1310  
  1311  		Overloads: []overload{
  1312  			{
  1313  				overloadId: 0,
  1314  				args:       []types.T{types.T_uint64},
  1315  				retType: func(parameters []types.Type) types.Type {
  1316  					return types.T_varchar.ToType()
  1317  				},
  1318  				newOp: func() executeLogicOfOverload {
  1319  					return SpaceNumber[uint64]
  1320  				},
  1321  			},
  1322  			{
  1323  				overloadId: 1,
  1324  				args:       []types.T{types.T_int64},
  1325  				retType: func(parameters []types.Type) types.Type {
  1326  					return types.T_varchar.ToType()
  1327  				},
  1328  				newOp: func() executeLogicOfOverload {
  1329  					return SpaceNumber[int64]
  1330  				},
  1331  			},
  1332  		},
  1333  	},
  1334  
  1335  	// function `split_part`
  1336  	{
  1337  		functionId: SPLIT_PART,
  1338  		class:      plan.Function_STRICT,
  1339  		layout:     STANDARD_FUNCTION,
  1340  		checkFn:    fixedTypeMatch,
  1341  
  1342  		Overloads: []overload{
  1343  			{
  1344  				overloadId: 0,
  1345  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_uint32},
  1346  				retType: func(parameters []types.Type) types.Type {
  1347  					return types.T_varchar.ToType()
  1348  				},
  1349  				newOp: func() executeLogicOfOverload {
  1350  					return SplitPart
  1351  				},
  1352  			},
  1353  		},
  1354  	},
  1355  
  1356  	// function `startswith`
  1357  	{
  1358  		functionId: STARTSWITH,
  1359  		class:      plan.Function_STRICT,
  1360  		layout:     STANDARD_FUNCTION,
  1361  		checkFn:    fixedTypeMatch,
  1362  
  1363  		Overloads: []overload{
  1364  			{
  1365  				overloadId: 0,
  1366  				args:       []types.T{types.T_varchar, types.T_varchar},
  1367  				retType: func(parameters []types.Type) types.Type {
  1368  					return types.T_bool.ToType()
  1369  				},
  1370  				newOp: func() executeLogicOfOverload {
  1371  					return StartsWith
  1372  				},
  1373  			},
  1374  		},
  1375  	},
  1376  
  1377  	// function `prefix_eq`
  1378  	{
  1379  		functionId: PREFIX_EQ,
  1380  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  1381  		layout:     STANDARD_FUNCTION,
  1382  		checkFn:    fixedDirectlyTypeMatch,
  1383  
  1384  		Overloads: []overload{
  1385  			{
  1386  				overloadId: 0,
  1387  				args:       []types.T{types.T_varchar, types.T_varchar},
  1388  				retType: func(parameters []types.Type) types.Type {
  1389  					return types.T_bool.ToType()
  1390  				},
  1391  				newOp: func() executeLogicOfOverload {
  1392  					return PrefixEq
  1393  				},
  1394  			},
  1395  		},
  1396  	},
  1397  
  1398  	// function `prefix_in`
  1399  	{
  1400  		functionId: PREFIX_IN,
  1401  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  1402  		layout:     STANDARD_FUNCTION,
  1403  		checkFn:    fixedDirectlyTypeMatch,
  1404  
  1405  		Overloads: []overload{
  1406  			{
  1407  				overloadId: 0,
  1408  				args:       []types.T{types.T_varchar, types.T_varchar},
  1409  				retType: func(parameters []types.Type) types.Type {
  1410  					return types.T_bool.ToType()
  1411  				},
  1412  				newOp: func() executeLogicOfOverload {
  1413  					return PrefixIn
  1414  				},
  1415  			},
  1416  		},
  1417  	},
  1418  
  1419  	// function `prefix_between`
  1420  	{
  1421  		functionId: PREFIX_BETWEEN,
  1422  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  1423  		layout:     STANDARD_FUNCTION,
  1424  		checkFn:    fixedDirectlyTypeMatch,
  1425  
  1426  		Overloads: []overload{
  1427  			{
  1428  				overloadId: 0,
  1429  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_varchar},
  1430  				retType: func(parameters []types.Type) types.Type {
  1431  					return types.T_bool.ToType()
  1432  				},
  1433  				newOp: func() executeLogicOfOverload {
  1434  					return PrefixBetween
  1435  				},
  1436  			},
  1437  		},
  1438  	},
  1439  	// to_base64
  1440  	{
  1441  		functionId: TO_BASE64,
  1442  		class:      plan.Function_STRICT,
  1443  		layout:     STANDARD_FUNCTION,
  1444  		checkFn:    fixedTypeMatch,
  1445  
  1446  		Overloads: []overload{
  1447  			{
  1448  				overloadId: 0,
  1449  				args:       []types.T{types.T_varchar},
  1450  				retType: func(parameters []types.Type) types.Type {
  1451  					return types.T_text.ToType()
  1452  				},
  1453  				newOp: func() executeLogicOfOverload {
  1454  					return ToBase64
  1455  				},
  1456  			},
  1457  			{
  1458  				overloadId: 1,
  1459  				args:       []types.T{types.T_array_float32},
  1460  				retType: func(parameters []types.Type) types.Type {
  1461  					return types.T_text.ToType()
  1462  				},
  1463  				newOp: func() executeLogicOfOverload {
  1464  					return ToBase64
  1465  				},
  1466  			},
  1467  			{
  1468  				overloadId: 2,
  1469  				args:       []types.T{types.T_array_float64},
  1470  				retType: func(parameters []types.Type) types.Type {
  1471  					return types.T_text.ToType()
  1472  				},
  1473  				newOp: func() executeLogicOfOverload {
  1474  					return ToBase64
  1475  				},
  1476  			},
  1477  		},
  1478  	},
  1479  
  1480  	// from_base64
  1481  	{
  1482  		functionId: FROM_BASE64,
  1483  		class:      plan.Function_STRICT,
  1484  		layout:     STANDARD_FUNCTION,
  1485  		checkFn:    fixedTypeMatch,
  1486  
  1487  		Overloads: []overload{
  1488  			{
  1489  				overloadId: 0,
  1490  				args:       []types.T{types.T_varchar},
  1491  				retType: func(parameters []types.Type) types.Type {
  1492  					return types.T_varchar.ToType()
  1493  				},
  1494  				newOp: func() executeLogicOfOverload {
  1495  					return FromBase64
  1496  				},
  1497  			},
  1498  		},
  1499  	},
  1500  
  1501  	// function `substring`, `substr`, `mid`
  1502  	{
  1503  		functionId: SUBSTRING,
  1504  		class:      plan.Function_STRICT,
  1505  		layout:     STANDARD_FUNCTION,
  1506  		checkFn:    fixedTypeMatch,
  1507  
  1508  		Overloads: []overload{
  1509  			{
  1510  				overloadId: 0,
  1511  				args:       []types.T{types.T_varchar, types.T_int64},
  1512  				retType: func(parameters []types.Type) types.Type {
  1513  					return types.T_varchar.ToType()
  1514  				},
  1515  				newOp: func() executeLogicOfOverload {
  1516  					return SubStringWith2Args
  1517  				},
  1518  			},
  1519  			{
  1520  				overloadId: 1,
  1521  				args:       []types.T{types.T_char, types.T_int64},
  1522  				retType: func(parameters []types.Type) types.Type {
  1523  					return types.T_char.ToType()
  1524  				},
  1525  				newOp: func() executeLogicOfOverload {
  1526  					return SubStringWith2Args
  1527  				},
  1528  			},
  1529  			{
  1530  				overloadId: 2,
  1531  				args:       []types.T{types.T_varchar, types.T_int64, types.T_int64},
  1532  				retType: func(parameters []types.Type) types.Type {
  1533  					return types.T_varchar.ToType()
  1534  				},
  1535  				newOp: func() executeLogicOfOverload {
  1536  					return SubStringWith3Args
  1537  				},
  1538  			},
  1539  			{
  1540  				overloadId: 3,
  1541  				args:       []types.T{types.T_char, types.T_int64, types.T_int64},
  1542  				retType: func(parameters []types.Type) types.Type {
  1543  					return types.T_char.ToType()
  1544  				},
  1545  				newOp: func() executeLogicOfOverload {
  1546  					return SubStringWith3Args
  1547  				},
  1548  			},
  1549  			{
  1550  				overloadId: 4,
  1551  				args:       []types.T{types.T_blob, types.T_int64, types.T_int64},
  1552  				retType: func(parameters []types.Type) types.Type {
  1553  					return types.T_blob.ToType()
  1554  				},
  1555  				newOp: func() executeLogicOfOverload {
  1556  					return SubStringWith3Args
  1557  				},
  1558  			},
  1559  			{
  1560  				overloadId: 5,
  1561  				args:       []types.T{types.T_text, types.T_int64, types.T_int64},
  1562  				retType: func(parameters []types.Type) types.Type {
  1563  					return types.T_text.ToType()
  1564  				},
  1565  				newOp: func() executeLogicOfOverload {
  1566  					return SubStringWith3Args
  1567  				},
  1568  			},
  1569  			{
  1570  				overloadId: 6,
  1571  				args:       []types.T{types.T_blob, types.T_int64},
  1572  				retType: func(parameters []types.Type) types.Type {
  1573  					return types.T_blob.ToType()
  1574  				},
  1575  				newOp: func() executeLogicOfOverload {
  1576  					return SubStringWith2Args
  1577  				},
  1578  			},
  1579  		},
  1580  	},
  1581  
  1582  	// function `substring_index`
  1583  	{
  1584  		functionId: SUBSTRING_INDEX,
  1585  		class:      plan.Function_STRICT,
  1586  		layout:     STANDARD_FUNCTION,
  1587  		checkFn:    fixedTypeMatch, // TODO:
  1588  
  1589  		Overloads: []overload{
  1590  			{
  1591  				overloadId: 0,
  1592  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_float64},
  1593  				retType: func(parameters []types.Type) types.Type {
  1594  					return types.T_varchar.ToType()
  1595  				},
  1596  				newOp: func() executeLogicOfOverload {
  1597  					return SubStrIndex[float64]
  1598  				},
  1599  			},
  1600  			{
  1601  				overloadId: 1,
  1602  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_uint64},
  1603  				retType: func(parameters []types.Type) types.Type {
  1604  					return types.T_varchar.ToType()
  1605  				},
  1606  				newOp: func() executeLogicOfOverload {
  1607  					return SubStrIndex[uint64]
  1608  				},
  1609  			},
  1610  			{
  1611  				overloadId: 1,
  1612  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_int64},
  1613  				retType: func(parameters []types.Type) types.Type {
  1614  					return types.T_varchar.ToType()
  1615  				},
  1616  				newOp: func() executeLogicOfOverload {
  1617  					return SubStrIndex[int64]
  1618  				},
  1619  			},
  1620  		},
  1621  	},
  1622  
  1623  	// function `trim`
  1624  	{
  1625  		functionId: TRIM,
  1626  		class:      plan.Function_STRICT,
  1627  		layout:     STANDARD_FUNCTION,
  1628  		checkFn:    fixedTypeMatch,
  1629  
  1630  		Overloads: []overload{
  1631  			{
  1632  				overloadId: 0,
  1633  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_varchar},
  1634  				retType: func(parameters []types.Type) types.Type {
  1635  					return types.T_varchar.ToType()
  1636  				},
  1637  				newOp: func() executeLogicOfOverload {
  1638  					return Trim
  1639  				},
  1640  			},
  1641  		},
  1642  	},
  1643  
  1644  	// function `lower`, `to_lower`
  1645  	{
  1646  		functionId: LOWER,
  1647  		class:      plan.Function_STRICT,
  1648  		layout:     STANDARD_FUNCTION,
  1649  		checkFn:    fixedTypeMatch,
  1650  
  1651  		Overloads: []overload{
  1652  			{
  1653  				overloadId: 0,
  1654  				args:       []types.T{types.T_varchar},
  1655  				retType: func(parameters []types.Type) types.Type {
  1656  					return parameters[0]
  1657  				},
  1658  				newOp: func() executeLogicOfOverload {
  1659  					return builtInToLower
  1660  				},
  1661  			},
  1662  		},
  1663  	},
  1664  
  1665  	// function `upper`, `to_upper`
  1666  	{
  1667  		functionId: UPPER,
  1668  		class:      plan.Function_STRICT,
  1669  		layout:     STANDARD_FUNCTION,
  1670  		checkFn:    fixedTypeMatch,
  1671  
  1672  		Overloads: []overload{
  1673  			{
  1674  				overloadId: 0,
  1675  				args:       []types.T{types.T_varchar},
  1676  				retType: func(parameters []types.Type) types.Type {
  1677  					return parameters[0]
  1678  				},
  1679  				newOp: func() executeLogicOfOverload {
  1680  					return builtInToUpper
  1681  				},
  1682  			},
  1683  		},
  1684  	},
  1685  
  1686  	// function `locate`
  1687  	{
  1688  		functionId: LOCATE,
  1689  		class:      plan.Function_STRICT,
  1690  		layout:     STANDARD_FUNCTION,
  1691  		checkFn:    fixedTypeMatch,
  1692  
  1693  		Overloads: []overload{
  1694  			{
  1695  				overloadId: 0,
  1696  				args:       []types.T{types.T_varchar, types.T_varchar},
  1697  				retType: func(parameters []types.Type) types.Type {
  1698  					return types.T_int64.ToType()
  1699  				},
  1700  				newOp: func() executeLogicOfOverload {
  1701  					return buildInLocate2Args
  1702  				},
  1703  			},
  1704  			{
  1705  				overloadId: 1,
  1706  				args:       []types.T{types.T_char, types.T_char},
  1707  				retType: func(parameters []types.Type) types.Type {
  1708  					return types.T_int64.ToType()
  1709  				},
  1710  				newOp: func() executeLogicOfOverload {
  1711  					return buildInLocate2Args
  1712  				},
  1713  			},
  1714  			{
  1715  				overloadId: 2,
  1716  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_int64},
  1717  				retType: func(parameters []types.Type) types.Type {
  1718  					return types.T_int64.ToType()
  1719  				},
  1720  				newOp: func() executeLogicOfOverload {
  1721  					return buildInLocate3Args
  1722  				},
  1723  			},
  1724  			{
  1725  				overloadId: 3,
  1726  				args:       []types.T{types.T_char, types.T_char, types.T_int64},
  1727  				retType: func(parameters []types.Type) types.Type {
  1728  					return types.T_int64.ToType()
  1729  				},
  1730  				newOp: func() executeLogicOfOverload {
  1731  					return buildInLocate3Args
  1732  				},
  1733  			},
  1734  		},
  1735  	},
  1736  
  1737  	// function `sha2`
  1738  	{
  1739  		functionId: SHA2,
  1740  		class:      plan.Function_STRICT,
  1741  		layout:     STANDARD_FUNCTION,
  1742  		checkFn:    fixedTypeMatch,
  1743  
  1744  		Overloads: []overload{
  1745  			{
  1746  				overloadId: 0,
  1747  				args:       []types.T{types.T_varchar, types.T_int64},
  1748  				retType: func(parameters []types.Type) types.Type {
  1749  					return types.T_varchar.ToType()
  1750  				},
  1751  				newOp: func() executeLogicOfOverload {
  1752  					return SHA2Func
  1753  				},
  1754  			},
  1755  		},
  1756  	},
  1757  }
  1758  
  1759  var supportedArrayOperations = []FuncNew{
  1760  
  1761  	// function `summation`
  1762  	{
  1763  		functionId: SUMMATION,
  1764  		class:      plan.Function_STRICT,
  1765  		layout:     STANDARD_FUNCTION,
  1766  		checkFn:    fixedTypeMatch,
  1767  
  1768  		Overloads: []overload{
  1769  			{
  1770  				overloadId: 0,
  1771  				args:       []types.T{types.T_array_float32},
  1772  				retType: func(parameters []types.Type) types.Type {
  1773  					// NOTE summation(vecf32) --> float64
  1774  					return types.T_float64.ToType()
  1775  				},
  1776  				newOp: func() executeLogicOfOverload {
  1777  					return SummationArray[float32]
  1778  				},
  1779  			},
  1780  			{
  1781  				overloadId: 1,
  1782  				args:       []types.T{types.T_array_float64},
  1783  				retType: func(parameters []types.Type) types.Type {
  1784  					return types.T_float64.ToType()
  1785  				},
  1786  				newOp: func() executeLogicOfOverload {
  1787  					return SummationArray[float64]
  1788  				},
  1789  			},
  1790  		},
  1791  	},
  1792  
  1793  	// function `l1_norm`
  1794  	{
  1795  		functionId: L1_NORM,
  1796  		class:      plan.Function_STRICT,
  1797  		layout:     STANDARD_FUNCTION,
  1798  		checkFn:    fixedTypeMatch,
  1799  
  1800  		Overloads: []overload{
  1801  			{
  1802  				overloadId: 0,
  1803  				args:       []types.T{types.T_array_float32},
  1804  				retType: func(parameters []types.Type) types.Type {
  1805  					return types.T_float64.ToType()
  1806  				},
  1807  				newOp: func() executeLogicOfOverload {
  1808  					return L1NormArray[float32]
  1809  				},
  1810  			},
  1811  			{
  1812  				overloadId: 1,
  1813  				args:       []types.T{types.T_array_float64},
  1814  				retType: func(parameters []types.Type) types.Type {
  1815  					return types.T_float64.ToType()
  1816  				},
  1817  				newOp: func() executeLogicOfOverload {
  1818  					return L1NormArray[float64]
  1819  				},
  1820  			},
  1821  		},
  1822  	},
  1823  
  1824  	// function `l2_norm`
  1825  	{
  1826  		functionId: L2_NORM,
  1827  		class:      plan.Function_STRICT,
  1828  		layout:     STANDARD_FUNCTION,
  1829  		checkFn:    fixedTypeMatch,
  1830  
  1831  		Overloads: []overload{
  1832  			{
  1833  				overloadId: 0,
  1834  				args:       []types.T{types.T_array_float32},
  1835  				retType: func(parameters []types.Type) types.Type {
  1836  					return types.T_float64.ToType()
  1837  				},
  1838  				newOp: func() executeLogicOfOverload {
  1839  					return L2NormArray[float32]
  1840  				},
  1841  			},
  1842  			{
  1843  				overloadId: 1,
  1844  				args:       []types.T{types.T_array_float64},
  1845  				retType: func(parameters []types.Type) types.Type {
  1846  					return types.T_float64.ToType()
  1847  				},
  1848  				newOp: func() executeLogicOfOverload {
  1849  					return L2NormArray[float64]
  1850  				},
  1851  			},
  1852  		},
  1853  	},
  1854  
  1855  	// function `vector_dims`
  1856  	{
  1857  		functionId: VECTOR_DIMS,
  1858  		class:      plan.Function_STRICT,
  1859  		layout:     STANDARD_FUNCTION,
  1860  		checkFn:    fixedTypeMatch,
  1861  
  1862  		Overloads: []overload{
  1863  			{
  1864  				overloadId: 0,
  1865  				args:       []types.T{types.T_array_float32},
  1866  				retType: func(parameters []types.Type) types.Type {
  1867  					return types.T_int64.ToType()
  1868  				},
  1869  				newOp: func() executeLogicOfOverload {
  1870  					return VectorDimsArray[float32]
  1871  				},
  1872  			},
  1873  			{
  1874  				overloadId: 1,
  1875  				args:       []types.T{types.T_array_float64},
  1876  				retType: func(parameters []types.Type) types.Type {
  1877  					return types.T_int64.ToType()
  1878  				},
  1879  				newOp: func() executeLogicOfOverload {
  1880  					return VectorDimsArray[float64]
  1881  				},
  1882  			},
  1883  		},
  1884  	},
  1885  
  1886  	// function `inner_product`
  1887  	{
  1888  		functionId: INNER_PRODUCT,
  1889  		class:      plan.Function_STRICT,
  1890  		layout:     STANDARD_FUNCTION,
  1891  		checkFn:    fixedTypeMatch,
  1892  
  1893  		Overloads: []overload{
  1894  			{
  1895  				overloadId: 0,
  1896  				args:       []types.T{types.T_array_float32, types.T_array_float32},
  1897  				retType: func(parameters []types.Type) types.Type {
  1898  					return types.T_float64.ToType()
  1899  				},
  1900  				newOp: func() executeLogicOfOverload {
  1901  					return InnerProductArray[float32]
  1902  				},
  1903  			},
  1904  			{
  1905  				overloadId: 1,
  1906  				args:       []types.T{types.T_array_float64, types.T_array_float64},
  1907  				retType: func(parameters []types.Type) types.Type {
  1908  					return types.T_float64.ToType()
  1909  				},
  1910  				newOp: func() executeLogicOfOverload {
  1911  					return InnerProductArray[float64]
  1912  				},
  1913  			},
  1914  		},
  1915  	},
  1916  
  1917  	// function `cosine_similarity`
  1918  	{
  1919  		functionId: COSINE_SIMILARITY,
  1920  		class:      plan.Function_STRICT,
  1921  		layout:     STANDARD_FUNCTION,
  1922  		checkFn:    fixedTypeMatch,
  1923  
  1924  		Overloads: []overload{
  1925  			{
  1926  				overloadId: 0,
  1927  				args:       []types.T{types.T_array_float32, types.T_array_float32},
  1928  				retType: func(parameters []types.Type) types.Type {
  1929  					return types.T_float64.ToType()
  1930  				},
  1931  				newOp: func() executeLogicOfOverload {
  1932  					return CosineSimilarityArray[float32]
  1933  				},
  1934  			},
  1935  			{
  1936  				overloadId: 1,
  1937  				args:       []types.T{types.T_array_float64, types.T_array_float64},
  1938  				retType: func(parameters []types.Type) types.Type {
  1939  					return types.T_float64.ToType()
  1940  				},
  1941  				newOp: func() executeLogicOfOverload {
  1942  					return CosineSimilarityArray[float64]
  1943  				},
  1944  			},
  1945  		},
  1946  	},
  1947  	// function `l2_distance`
  1948  	{
  1949  		functionId: L2_DISTANCE,
  1950  		class:      plan.Function_STRICT,
  1951  		layout:     STANDARD_FUNCTION,
  1952  		checkFn:    fixedTypeMatch,
  1953  
  1954  		Overloads: []overload{
  1955  			{
  1956  				overloadId: 0,
  1957  				args:       []types.T{types.T_array_float32, types.T_array_float32},
  1958  				retType: func(parameters []types.Type) types.Type {
  1959  					return types.T_float64.ToType()
  1960  				},
  1961  				newOp: func() executeLogicOfOverload {
  1962  					return L2DistanceArray[float32]
  1963  				},
  1964  			},
  1965  			{
  1966  				overloadId: 1,
  1967  				args:       []types.T{types.T_array_float64, types.T_array_float64},
  1968  				retType: func(parameters []types.Type) types.Type {
  1969  					return types.T_float64.ToType()
  1970  				},
  1971  				newOp: func() executeLogicOfOverload {
  1972  					return L2DistanceArray[float64]
  1973  				},
  1974  			},
  1975  		},
  1976  	},
  1977  	// function `cosine_distance`
  1978  	{
  1979  		functionId: COSINE_DISTANCE,
  1980  		class:      plan.Function_STRICT,
  1981  		layout:     STANDARD_FUNCTION,
  1982  		checkFn:    fixedTypeMatch,
  1983  
  1984  		Overloads: []overload{
  1985  			{
  1986  				overloadId: 0,
  1987  				args:       []types.T{types.T_array_float32, types.T_array_float32},
  1988  				retType: func(parameters []types.Type) types.Type {
  1989  					return types.T_float64.ToType()
  1990  				},
  1991  				newOp: func() executeLogicOfOverload {
  1992  					return CosineDistanceArray[float32]
  1993  				},
  1994  			},
  1995  			{
  1996  				overloadId: 1,
  1997  				args:       []types.T{types.T_array_float64, types.T_array_float64},
  1998  				retType: func(parameters []types.Type) types.Type {
  1999  					return types.T_float64.ToType()
  2000  				},
  2001  				newOp: func() executeLogicOfOverload {
  2002  					return CosineDistanceArray[float64]
  2003  				},
  2004  			},
  2005  		},
  2006  	},
  2007  	// function `normalize_l2`
  2008  	{
  2009  		functionId: NORMALIZE_L2,
  2010  		class:      plan.Function_STRICT,
  2011  		layout:     STANDARD_FUNCTION,
  2012  		checkFn:    fixedTypeMatch,
  2013  
  2014  		Overloads: []overload{
  2015  			{
  2016  				overloadId: 1,
  2017  				args:       []types.T{types.T_array_float32},
  2018  				retType: func(parameters []types.Type) types.Type {
  2019  					return parameters[0]
  2020  				},
  2021  				newOp: func() executeLogicOfOverload {
  2022  					return NormalizeL2Array[float32]
  2023  				},
  2024  			},
  2025  			{
  2026  				overloadId: 2,
  2027  				args:       []types.T{types.T_array_float64},
  2028  				retType: func(parameters []types.Type) types.Type {
  2029  					return parameters[0]
  2030  				},
  2031  				newOp: func() executeLogicOfOverload {
  2032  					return NormalizeL2Array[float64]
  2033  				},
  2034  			},
  2035  		},
  2036  	},
  2037  	// function `subvector`
  2038  	{
  2039  		functionId: SUB_VECTOR,
  2040  		class:      plan.Function_STRICT,
  2041  		layout:     STANDARD_FUNCTION,
  2042  		checkFn:    fixedTypeMatch,
  2043  
  2044  		Overloads: []overload{
  2045  			{
  2046  				overloadId: 0,
  2047  				args:       []types.T{types.T_array_float32, types.T_int64},
  2048  				retType: func(parameters []types.Type) types.Type {
  2049  					return types.T_array_float32.ToType()
  2050  				},
  2051  				newOp: func() executeLogicOfOverload {
  2052  					return SubVectorWith2Args[float32]
  2053  				},
  2054  			},
  2055  			{
  2056  				overloadId: 1,
  2057  				args:       []types.T{types.T_array_float64, types.T_int64},
  2058  				retType: func(parameters []types.Type) types.Type {
  2059  					return types.T_array_float64.ToType()
  2060  				},
  2061  				newOp: func() executeLogicOfOverload {
  2062  					return SubVectorWith2Args[float64]
  2063  				},
  2064  			},
  2065  			{
  2066  				overloadId: 2,
  2067  				args:       []types.T{types.T_array_float32, types.T_int64, types.T_int64},
  2068  				retType: func(parameters []types.Type) types.Type {
  2069  					return types.T_array_float32.ToType()
  2070  				},
  2071  				newOp: func() executeLogicOfOverload {
  2072  					return SubVectorWith3Args[float32]
  2073  				},
  2074  			},
  2075  			{
  2076  				overloadId: 3,
  2077  				args:       []types.T{types.T_array_float64, types.T_int64, types.T_int64},
  2078  				retType: func(parameters []types.Type) types.Type {
  2079  					return types.T_array_float64.ToType()
  2080  				},
  2081  				newOp: func() executeLogicOfOverload {
  2082  					return SubVectorWith3Args[float64]
  2083  				},
  2084  			},
  2085  		},
  2086  	},
  2087  }
  2088  
  2089  var supportedMathBuiltIns = []FuncNew{
  2090  	// function `abs`
  2091  	{
  2092  		functionId: ABS,
  2093  		class:      plan.Function_STRICT,
  2094  		layout:     STANDARD_FUNCTION,
  2095  		checkFn:    fixedTypeMatch,
  2096  
  2097  		Overloads: []overload{
  2098  			{
  2099  				overloadId: 0,
  2100  				args:       []types.T{types.T_int64},
  2101  				retType: func(parameters []types.Type) types.Type {
  2102  					return types.T_int64.ToType()
  2103  				},
  2104  				newOp: func() executeLogicOfOverload {
  2105  					return AbsInt64
  2106  				},
  2107  			},
  2108  			{
  2109  				overloadId: 1,
  2110  				args:       []types.T{types.T_uint64},
  2111  				retType: func(parameters []types.Type) types.Type {
  2112  					return types.T_uint64.ToType()
  2113  				},
  2114  				newOp: func() executeLogicOfOverload {
  2115  					return AbsUInt64
  2116  				},
  2117  			},
  2118  			{
  2119  				overloadId: 2,
  2120  				args:       []types.T{types.T_float64},
  2121  				retType: func(parameters []types.Type) types.Type {
  2122  					return types.T_float64.ToType()
  2123  				},
  2124  				newOp: func() executeLogicOfOverload {
  2125  					return AbsFloat64
  2126  				},
  2127  			},
  2128  			{
  2129  				overloadId: 3,
  2130  				args:       []types.T{types.T_decimal64},
  2131  				retType: func(parameters []types.Type) types.Type {
  2132  					return parameters[0]
  2133  				},
  2134  				newOp: func() executeLogicOfOverload {
  2135  					return AbsDecimal64
  2136  				},
  2137  			},
  2138  			{
  2139  				overloadId: 4,
  2140  				args:       []types.T{types.T_decimal128},
  2141  				retType: func(parameters []types.Type) types.Type {
  2142  					return parameters[0]
  2143  				},
  2144  				newOp: func() executeLogicOfOverload {
  2145  					return AbsDecimal128
  2146  				},
  2147  			},
  2148  			{
  2149  				overloadId: 5,
  2150  				args:       []types.T{types.T_array_float32},
  2151  				retType: func(parameters []types.Type) types.Type {
  2152  					return parameters[0]
  2153  				},
  2154  				newOp: func() executeLogicOfOverload {
  2155  					return AbsArray[float32]
  2156  				},
  2157  			},
  2158  			{
  2159  				overloadId: 6,
  2160  				args:       []types.T{types.T_array_float64},
  2161  				retType: func(parameters []types.Type) types.Type {
  2162  					return parameters[0]
  2163  				},
  2164  				newOp: func() executeLogicOfOverload {
  2165  					return AbsArray[float64]
  2166  				},
  2167  			},
  2168  		},
  2169  	},
  2170  	// function `sqrt`
  2171  	{
  2172  		functionId: SQRT,
  2173  		class:      plan.Function_STRICT,
  2174  		layout:     STANDARD_FUNCTION,
  2175  		checkFn:    fixedTypeMatch,
  2176  
  2177  		Overloads: []overload{
  2178  			{
  2179  				overloadId: 0,
  2180  				args:       []types.T{types.T_float64},
  2181  				retType: func(parameters []types.Type) types.Type {
  2182  					return types.T_float64.ToType()
  2183  				},
  2184  				newOp: func() executeLogicOfOverload {
  2185  					return builtInSqrt
  2186  				},
  2187  			},
  2188  			{
  2189  				overloadId: 1,
  2190  				args:       []types.T{types.T_array_float32},
  2191  				retType: func(parameters []types.Type) types.Type {
  2192  					return types.T_array_float64.ToType()
  2193  				},
  2194  				newOp: func() executeLogicOfOverload {
  2195  					return builtInSqrtArray[float32]
  2196  				},
  2197  			},
  2198  			{
  2199  				overloadId: 2,
  2200  				args:       []types.T{types.T_array_float64},
  2201  				retType: func(parameters []types.Type) types.Type {
  2202  					return types.T_array_float64.ToType()
  2203  				},
  2204  				newOp: func() executeLogicOfOverload {
  2205  					return builtInSqrtArray[float64]
  2206  				},
  2207  			},
  2208  		},
  2209  	},
  2210  	// function `acos`
  2211  	{
  2212  		functionId: ACOS,
  2213  		class:      plan.Function_STRICT,
  2214  		layout:     STANDARD_FUNCTION,
  2215  		checkFn:    fixedTypeMatch,
  2216  
  2217  		Overloads: []overload{
  2218  			{
  2219  				overloadId: 0,
  2220  				args:       []types.T{types.T_float64},
  2221  				retType: func(parameters []types.Type) types.Type {
  2222  					return types.T_float64.ToType()
  2223  				},
  2224  				newOp: func() executeLogicOfOverload {
  2225  					return builtInACos
  2226  				},
  2227  			},
  2228  		},
  2229  	},
  2230  
  2231  	// function `atan`
  2232  	{
  2233  		functionId: ATAN,
  2234  		class:      plan.Function_STRICT,
  2235  		layout:     STANDARD_FUNCTION,
  2236  		checkFn:    fixedTypeMatch,
  2237  
  2238  		Overloads: []overload{
  2239  			{
  2240  				overloadId: 0,
  2241  				args:       []types.T{types.T_float64},
  2242  				retType: func(parameters []types.Type) types.Type {
  2243  					return types.T_float64.ToType()
  2244  				},
  2245  				newOp: func() executeLogicOfOverload {
  2246  					return builtInATan
  2247  				},
  2248  			},
  2249  
  2250  			{
  2251  				overloadId: 1,
  2252  				args:       []types.T{types.T_float64, types.T_float64},
  2253  				retType: func(parameters []types.Type) types.Type {
  2254  					return types.T_float64.ToType()
  2255  				},
  2256  				newOp: func() executeLogicOfOverload {
  2257  					return builtInATan2
  2258  				},
  2259  			},
  2260  		},
  2261  	},
  2262  
  2263  	// function `bin`
  2264  	{
  2265  		functionId: BIN,
  2266  		class:      plan.Function_STRICT,
  2267  		layout:     STANDARD_FUNCTION,
  2268  		checkFn:    fixedTypeMatch,
  2269  
  2270  		Overloads: []overload{
  2271  			{
  2272  				overloadId: 0,
  2273  				args:       []types.T{types.T_uint8},
  2274  				retType: func(parameters []types.Type) types.Type {
  2275  					return types.T_varchar.ToType()
  2276  				},
  2277  				newOp: func() executeLogicOfOverload {
  2278  					return Bin[uint8]
  2279  				},
  2280  			},
  2281  			{
  2282  				overloadId: 1,
  2283  				args:       []types.T{types.T_uint16},
  2284  				retType: func(parameters []types.Type) types.Type {
  2285  					return types.T_varchar.ToType()
  2286  				},
  2287  				newOp: func() executeLogicOfOverload {
  2288  					return Bin[uint16]
  2289  				},
  2290  			},
  2291  			{
  2292  				overloadId: 2,
  2293  				args:       []types.T{types.T_uint32},
  2294  				retType: func(parameters []types.Type) types.Type {
  2295  					return types.T_varchar.ToType()
  2296  				},
  2297  				newOp: func() executeLogicOfOverload {
  2298  					return Bin[uint32]
  2299  				},
  2300  			},
  2301  			{
  2302  				overloadId: 3,
  2303  				args:       []types.T{types.T_uint64},
  2304  				retType: func(parameters []types.Type) types.Type {
  2305  					return types.T_varchar.ToType()
  2306  				},
  2307  				newOp: func() executeLogicOfOverload {
  2308  					return Bin[uint64]
  2309  				},
  2310  			},
  2311  			{
  2312  				overloadId: 4,
  2313  				args:       []types.T{types.T_int8},
  2314  				retType: func(parameters []types.Type) types.Type {
  2315  					return types.T_varchar.ToType()
  2316  				},
  2317  				newOp: func() executeLogicOfOverload {
  2318  					return Bin[int8]
  2319  				},
  2320  			},
  2321  			{
  2322  				overloadId: 5,
  2323  				args:       []types.T{types.T_int16},
  2324  				retType: func(parameters []types.Type) types.Type {
  2325  					return types.T_varchar.ToType()
  2326  				},
  2327  				newOp: func() executeLogicOfOverload {
  2328  					return Bin[int16]
  2329  				},
  2330  			},
  2331  			{
  2332  				overloadId: 6,
  2333  				args:       []types.T{types.T_int32},
  2334  				retType: func(parameters []types.Type) types.Type {
  2335  					return types.T_varchar.ToType()
  2336  				},
  2337  				newOp: func() executeLogicOfOverload {
  2338  					return Bin[int32]
  2339  				},
  2340  			},
  2341  			{
  2342  				overloadId: 7,
  2343  				args:       []types.T{types.T_int64},
  2344  				retType: func(parameters []types.Type) types.Type {
  2345  					return types.T_varchar.ToType()
  2346  				},
  2347  				newOp: func() executeLogicOfOverload {
  2348  					return Bin[int64]
  2349  				},
  2350  			},
  2351  			{
  2352  				overloadId: 8,
  2353  				args:       []types.T{types.T_float32},
  2354  				retType: func(parameters []types.Type) types.Type {
  2355  					return types.T_varchar.ToType()
  2356  				},
  2357  				newOp: func() executeLogicOfOverload {
  2358  					return BinFloat[float32]
  2359  				},
  2360  			},
  2361  			{
  2362  				overloadId: 9,
  2363  				args:       []types.T{types.T_float64},
  2364  				retType: func(parameters []types.Type) types.Type {
  2365  					return types.T_varchar.ToType()
  2366  				},
  2367  				newOp: func() executeLogicOfOverload {
  2368  					return BinFloat[float64]
  2369  				},
  2370  			},
  2371  		},
  2372  	},
  2373  
  2374  	// function `ceil`, `ceiling`
  2375  	{
  2376  		functionId: CEIL,
  2377  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  2378  		layout:     STANDARD_FUNCTION,
  2379  		checkFn:    fixedTypeMatch,
  2380  
  2381  		Overloads: []overload{
  2382  			{
  2383  				overloadId: 0,
  2384  				args:       []types.T{types.T_uint64},
  2385  				retType: func(parameters []types.Type) types.Type {
  2386  					return types.T_uint64.ToType()
  2387  				},
  2388  				newOp: func() executeLogicOfOverload {
  2389  					return CeilUint64
  2390  				},
  2391  			},
  2392  			{
  2393  				overloadId: 1,
  2394  				args:       []types.T{types.T_uint64, types.T_int64},
  2395  				retType: func(parameters []types.Type) types.Type {
  2396  					return types.T_uint64.ToType()
  2397  				},
  2398  				newOp: func() executeLogicOfOverload {
  2399  					return CeilUint64
  2400  				},
  2401  			},
  2402  			{
  2403  				overloadId: 2,
  2404  				args:       []types.T{types.T_int64},
  2405  				retType: func(parameters []types.Type) types.Type {
  2406  					return types.T_int64.ToType()
  2407  				},
  2408  				newOp: func() executeLogicOfOverload {
  2409  					return CeilInt64
  2410  				},
  2411  			},
  2412  			{
  2413  				overloadId: 3,
  2414  				args:       []types.T{types.T_int64, types.T_int64},
  2415  				retType: func(parameters []types.Type) types.Type {
  2416  					return types.T_int64.ToType()
  2417  				},
  2418  				newOp: func() executeLogicOfOverload {
  2419  					return CeilInt64
  2420  				},
  2421  			},
  2422  			{
  2423  				overloadId: 4,
  2424  				args:       []types.T{types.T_float64},
  2425  				retType: func(parameters []types.Type) types.Type {
  2426  					return types.T_float64.ToType()
  2427  				},
  2428  				newOp: func() executeLogicOfOverload {
  2429  					return CeilFloat64
  2430  				},
  2431  			},
  2432  			{
  2433  				overloadId: 5,
  2434  				args:       []types.T{types.T_float64, types.T_int64},
  2435  				retType: func(parameters []types.Type) types.Type {
  2436  					return types.T_float64.ToType()
  2437  				},
  2438  				newOp: func() executeLogicOfOverload {
  2439  					return CeilFloat64
  2440  				},
  2441  			},
  2442  			{
  2443  				overloadId: 6,
  2444  				args:       []types.T{types.T_decimal64},
  2445  				retType: func(parameters []types.Type) types.Type {
  2446  					return parameters[0]
  2447  				},
  2448  				newOp: func() executeLogicOfOverload {
  2449  					return CeilDecimal64
  2450  				},
  2451  			},
  2452  			{
  2453  				overloadId: 7,
  2454  				args:       []types.T{types.T_decimal64, types.T_int64},
  2455  				retType: func(parameters []types.Type) types.Type {
  2456  					return parameters[0]
  2457  				},
  2458  				newOp: func() executeLogicOfOverload {
  2459  					return CeilDecimal64
  2460  				},
  2461  			},
  2462  			{
  2463  				overloadId: 8,
  2464  				args:       []types.T{types.T_decimal128},
  2465  				retType: func(parameters []types.Type) types.Type {
  2466  					return parameters[0]
  2467  				},
  2468  				newOp: func() executeLogicOfOverload {
  2469  					return CeilDecimal128
  2470  				},
  2471  			},
  2472  			{
  2473  				overloadId: 9,
  2474  				args:       []types.T{types.T_decimal128, types.T_int64},
  2475  				retType: func(parameters []types.Type) types.Type {
  2476  					return parameters[0]
  2477  				},
  2478  				newOp: func() executeLogicOfOverload {
  2479  					return CeilDecimal128
  2480  				},
  2481  			},
  2482  			{
  2483  				overloadId: 10,
  2484  				args:       []types.T{types.T_varchar},
  2485  				retType: func(parameters []types.Type) types.Type {
  2486  					return types.T_float64.ToType()
  2487  				},
  2488  				newOp: func() executeLogicOfOverload {
  2489  					return CeilStr
  2490  				},
  2491  			},
  2492  		},
  2493  	},
  2494  
  2495  	// function `cos`
  2496  	{
  2497  		functionId: COS,
  2498  		class:      plan.Function_STRICT,
  2499  		layout:     STANDARD_FUNCTION,
  2500  		checkFn:    fixedTypeMatch,
  2501  
  2502  		Overloads: []overload{
  2503  			{
  2504  				overloadId: 0,
  2505  				args:       []types.T{types.T_float64},
  2506  				retType: func(parameters []types.Type) types.Type {
  2507  					return types.T_float64.ToType()
  2508  				},
  2509  				newOp: func() executeLogicOfOverload {
  2510  					return builtInCos
  2511  				},
  2512  			},
  2513  		},
  2514  	},
  2515  
  2516  	// function `cot`
  2517  	{
  2518  		functionId: COT,
  2519  		class:      plan.Function_STRICT,
  2520  		layout:     STANDARD_FUNCTION,
  2521  		checkFn:    fixedTypeMatch,
  2522  
  2523  		Overloads: []overload{
  2524  			{
  2525  				overloadId: 0,
  2526  				args:       []types.T{types.T_float64},
  2527  				retType: func(parameters []types.Type) types.Type {
  2528  					return types.T_float64.ToType()
  2529  				},
  2530  				newOp: func() executeLogicOfOverload {
  2531  					return builtInCot
  2532  				},
  2533  			},
  2534  		},
  2535  	},
  2536  
  2537  	// function `exp`
  2538  	{
  2539  		functionId: EXP,
  2540  		class:      plan.Function_STRICT,
  2541  		layout:     STANDARD_FUNCTION,
  2542  		checkFn:    fixedTypeMatch,
  2543  
  2544  		Overloads: []overload{
  2545  			{
  2546  				overloadId: 0,
  2547  				args:       []types.T{types.T_float64},
  2548  				retType: func(parameters []types.Type) types.Type {
  2549  					return types.T_float64.ToType()
  2550  				},
  2551  				newOp: func() executeLogicOfOverload {
  2552  					return builtInExp
  2553  				},
  2554  			},
  2555  		},
  2556  	},
  2557  
  2558  	// function `floor`
  2559  	{
  2560  		functionId: FLOOR,
  2561  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  2562  		layout:     STANDARD_FUNCTION,
  2563  		checkFn:    fixedTypeMatch,
  2564  
  2565  		Overloads: []overload{
  2566  			{
  2567  				overloadId: 0,
  2568  				args:       []types.T{types.T_uint64},
  2569  				retType: func(parameters []types.Type) types.Type {
  2570  					return types.T_uint64.ToType()
  2571  				},
  2572  				newOp: func() executeLogicOfOverload {
  2573  					return FloorUInt64
  2574  				},
  2575  			},
  2576  			{
  2577  				overloadId: 1,
  2578  				args:       []types.T{types.T_uint64, types.T_int64},
  2579  				retType: func(parameters []types.Type) types.Type {
  2580  					return types.T_uint64.ToType()
  2581  				},
  2582  				newOp: func() executeLogicOfOverload {
  2583  					return FloorUInt64
  2584  				},
  2585  			},
  2586  			{
  2587  				overloadId: 2,
  2588  				args:       []types.T{types.T_int64},
  2589  				retType: func(parameters []types.Type) types.Type {
  2590  					return types.T_int64.ToType()
  2591  				},
  2592  				newOp: func() executeLogicOfOverload {
  2593  					return FloorInt64
  2594  				},
  2595  			},
  2596  			{
  2597  				overloadId: 3,
  2598  				args:       []types.T{types.T_int64, types.T_int64},
  2599  				retType: func(parameters []types.Type) types.Type {
  2600  					return types.T_int64.ToType()
  2601  				},
  2602  				newOp: func() executeLogicOfOverload {
  2603  					return FloorInt64
  2604  				},
  2605  			},
  2606  			{
  2607  				overloadId: 4,
  2608  				args:       []types.T{types.T_float64},
  2609  				retType: func(parameters []types.Type) types.Type {
  2610  					return types.T_float64.ToType()
  2611  				},
  2612  				newOp: func() executeLogicOfOverload {
  2613  					return FloorFloat64
  2614  				},
  2615  			},
  2616  			{
  2617  				overloadId: 5,
  2618  				args:       []types.T{types.T_float64, types.T_int64},
  2619  				retType: func(parameters []types.Type) types.Type {
  2620  					return types.T_float64.ToType()
  2621  				},
  2622  				newOp: func() executeLogicOfOverload {
  2623  					return FloorFloat64
  2624  				},
  2625  			},
  2626  			{
  2627  				overloadId: 6,
  2628  				args:       []types.T{types.T_decimal64},
  2629  				retType: func(parameters []types.Type) types.Type {
  2630  					return parameters[0]
  2631  				},
  2632  				newOp: func() executeLogicOfOverload {
  2633  					return FloorDecimal64
  2634  				},
  2635  			},
  2636  			{
  2637  				overloadId: 7,
  2638  				args:       []types.T{types.T_decimal64, types.T_int64},
  2639  				retType: func(parameters []types.Type) types.Type {
  2640  					return parameters[0]
  2641  				},
  2642  				newOp: func() executeLogicOfOverload {
  2643  					return FloorDecimal64
  2644  				},
  2645  			},
  2646  			{
  2647  				overloadId: 8,
  2648  				args:       []types.T{types.T_decimal128},
  2649  				retType: func(parameters []types.Type) types.Type {
  2650  					return parameters[0]
  2651  				},
  2652  				newOp: func() executeLogicOfOverload {
  2653  					return FloorDecimal128
  2654  				},
  2655  			},
  2656  			{
  2657  				overloadId: 9,
  2658  				args:       []types.T{types.T_decimal128, types.T_int64},
  2659  				retType: func(parameters []types.Type) types.Type {
  2660  					return parameters[0]
  2661  				},
  2662  				newOp: func() executeLogicOfOverload {
  2663  					return FloorDecimal128
  2664  				},
  2665  			},
  2666  			{
  2667  				overloadId: 10,
  2668  				args:       []types.T{types.T_varchar},
  2669  				retType: func(parameters []types.Type) types.Type {
  2670  					return types.T_float64.ToType()
  2671  				},
  2672  				newOp: func() executeLogicOfOverload {
  2673  					return FloorStr
  2674  				},
  2675  			},
  2676  		},
  2677  	},
  2678  
  2679  	// function `hex`
  2680  	{
  2681  		functionId: HEX,
  2682  		class:      plan.Function_STRICT,
  2683  		layout:     STANDARD_FUNCTION,
  2684  		checkFn:    fixedTypeMatch,
  2685  
  2686  		Overloads: []overload{
  2687  			{
  2688  				overloadId: 0,
  2689  				args:       []types.T{types.T_varchar},
  2690  				retType: func(parameters []types.Type) types.Type {
  2691  					return types.T_varchar.ToType()
  2692  				},
  2693  				newOp: func() executeLogicOfOverload {
  2694  					return HexString
  2695  				},
  2696  			},
  2697  			{
  2698  				overloadId: 1,
  2699  				args:       []types.T{types.T_char},
  2700  				retType: func(parameters []types.Type) types.Type {
  2701  					return types.T_varchar.ToType()
  2702  				},
  2703  				newOp: func() executeLogicOfOverload {
  2704  					return HexString
  2705  				},
  2706  			},
  2707  			{
  2708  				overloadId: 2,
  2709  				args:       []types.T{types.T_int64},
  2710  				retType: func(parameters []types.Type) types.Type {
  2711  					return types.T_varchar.ToType()
  2712  				},
  2713  				newOp: func() executeLogicOfOverload {
  2714  					return HexInt64
  2715  				},
  2716  			},
  2717  			{
  2718  				overloadId: 3,
  2719  				args:       []types.T{types.T_uint64},
  2720  				retType: func(parameters []types.Type) types.Type {
  2721  					return types.T_varchar.ToType()
  2722  				},
  2723  				newOp: func() executeLogicOfOverload {
  2724  					return HexUint64
  2725  				},
  2726  			},
  2727  			{
  2728  				overloadId: 4,
  2729  				args:       []types.T{types.T_array_float32},
  2730  				retType: func(parameters []types.Type) types.Type {
  2731  					return types.T_varchar.ToType()
  2732  				},
  2733  				newOp: func() executeLogicOfOverload {
  2734  					return HexArray
  2735  				},
  2736  			},
  2737  			{
  2738  				overloadId: 5,
  2739  				args:       []types.T{types.T_array_float64},
  2740  				retType: func(parameters []types.Type) types.Type {
  2741  					return types.T_varchar.ToType()
  2742  				},
  2743  				newOp: func() executeLogicOfOverload {
  2744  					return HexArray
  2745  				},
  2746  			},
  2747  		},
  2748  	},
  2749  
  2750  	// function `unhex`
  2751  	{
  2752  		functionId: UNHEX,
  2753  		class:      plan.Function_STRICT,
  2754  		layout:     STANDARD_FUNCTION,
  2755  		checkFn:    fixedTypeMatch,
  2756  
  2757  		Overloads: []overload{
  2758  			{
  2759  				overloadId: 0,
  2760  				args:       []types.T{types.T_varchar},
  2761  				retType: func(parameters []types.Type) types.Type {
  2762  					return types.T_varchar.ToType()
  2763  				},
  2764  				newOp: func() executeLogicOfOverload {
  2765  					return Unhex
  2766  				},
  2767  			},
  2768  		},
  2769  	},
  2770  
  2771  	// function `md5`
  2772  	{
  2773  		functionId: MD5,
  2774  		class:      plan.Function_STRICT,
  2775  		layout:     STANDARD_FUNCTION,
  2776  		checkFn:    fixedTypeMatch,
  2777  
  2778  		Overloads: []overload{
  2779  			{
  2780  				overloadId: 0,
  2781  				args:       []types.T{types.T_varchar},
  2782  				retType: func(parameters []types.Type) types.Type {
  2783  					return types.T_varchar.ToType()
  2784  				},
  2785  				newOp: func() executeLogicOfOverload {
  2786  					return Md5
  2787  				},
  2788  			},
  2789  		},
  2790  	},
  2791  
  2792  	// function `ln`
  2793  	{
  2794  		functionId: LN,
  2795  		class:      plan.Function_STRICT,
  2796  		layout:     STANDARD_FUNCTION,
  2797  		checkFn:    fixedTypeMatch,
  2798  
  2799  		Overloads: []overload{
  2800  			{
  2801  				overloadId: 0,
  2802  				args:       []types.T{types.T_float64},
  2803  				retType: func(parameters []types.Type) types.Type {
  2804  					return types.T_float64.ToType()
  2805  				},
  2806  				newOp: func() executeLogicOfOverload {
  2807  					return builtInLn
  2808  				},
  2809  			},
  2810  		},
  2811  	},
  2812  
  2813  	// function `log`
  2814  	{
  2815  		functionId: LOG,
  2816  		class:      plan.Function_STRICT,
  2817  		layout:     STANDARD_FUNCTION,
  2818  		checkFn:    fixedTypeMatch,
  2819  
  2820  		Overloads: []overload{
  2821  			{
  2822  				overloadId: 0,
  2823  				args:       []types.T{types.T_float64},
  2824  				retType: func(parameters []types.Type) types.Type {
  2825  					return types.T_float64.ToType()
  2826  				},
  2827  				newOp: func() executeLogicOfOverload {
  2828  					return builtInLn
  2829  				},
  2830  			},
  2831  			{
  2832  				overloadId: 1,
  2833  				args:       []types.T{types.T_float64, types.T_float64},
  2834  				retType: func(parameters []types.Type) types.Type {
  2835  					return types.T_float64.ToType()
  2836  				},
  2837  				newOp: func() executeLogicOfOverload {
  2838  					return builtInLog
  2839  				},
  2840  			},
  2841  		},
  2842  	},
  2843  
  2844  	// function `log2`
  2845  	{
  2846  		functionId: LOG2,
  2847  		class:      plan.Function_STRICT,
  2848  		layout:     STANDARD_FUNCTION,
  2849  		checkFn:    fixedTypeMatch,
  2850  
  2851  		Overloads: []overload{
  2852  			{
  2853  				overloadId: 0,
  2854  				args:       []types.T{types.T_float64},
  2855  				retType: func(parameters []types.Type) types.Type {
  2856  					return types.T_float64.ToType()
  2857  				},
  2858  				newOp: func() executeLogicOfOverload {
  2859  					return builtInLog2
  2860  				},
  2861  			},
  2862  		},
  2863  	},
  2864  
  2865  	// function `log10`
  2866  	{
  2867  		functionId: LOG10,
  2868  		class:      plan.Function_STRICT,
  2869  		layout:     STANDARD_FUNCTION,
  2870  		checkFn:    fixedTypeMatch,
  2871  
  2872  		Overloads: []overload{
  2873  			{
  2874  				overloadId: 0,
  2875  				args:       []types.T{types.T_float64},
  2876  				retType: func(parameters []types.Type) types.Type {
  2877  					return types.T_float64.ToType()
  2878  				},
  2879  				newOp: func() executeLogicOfOverload {
  2880  					return builtInLog10
  2881  				},
  2882  			},
  2883  		},
  2884  	},
  2885  
  2886  	// function `oct`
  2887  	{
  2888  		functionId: OCT,
  2889  		class:      plan.Function_STRICT,
  2890  		layout:     STANDARD_FUNCTION,
  2891  		checkFn:    fixedTypeMatch,
  2892  
  2893  		Overloads: []overload{
  2894  			{
  2895  				overloadId: 0,
  2896  				args:       []types.T{types.T_uint8},
  2897  				retType: func(parameters []types.Type) types.Type {
  2898  					return types.T_decimal128.ToType()
  2899  				},
  2900  				newOp: func() executeLogicOfOverload {
  2901  					return Oct[uint8]
  2902  				},
  2903  			},
  2904  			{
  2905  				overloadId: 1,
  2906  				args:       []types.T{types.T_uint16},
  2907  				retType: func(parameters []types.Type) types.Type {
  2908  					return types.T_decimal128.ToType()
  2909  				},
  2910  				newOp: func() executeLogicOfOverload {
  2911  					return Oct[uint16]
  2912  				},
  2913  			},
  2914  			{
  2915  				overloadId: 2,
  2916  				args:       []types.T{types.T_uint32},
  2917  				retType: func(parameters []types.Type) types.Type {
  2918  					return types.T_decimal128.ToType()
  2919  				},
  2920  				newOp: func() executeLogicOfOverload {
  2921  					return Oct[uint32]
  2922  				},
  2923  			},
  2924  			{
  2925  				overloadId: 3,
  2926  				args:       []types.T{types.T_uint64},
  2927  				retType: func(parameters []types.Type) types.Type {
  2928  					return types.T_decimal128.ToType()
  2929  				},
  2930  				newOp: func() executeLogicOfOverload {
  2931  					return Oct[uint64]
  2932  				},
  2933  			},
  2934  			{
  2935  				overloadId: 4,
  2936  				args:       []types.T{types.T_int8},
  2937  				retType: func(parameters []types.Type) types.Type {
  2938  					return types.T_decimal128.ToType()
  2939  				},
  2940  				newOp: func() executeLogicOfOverload {
  2941  					return Oct[int8]
  2942  				},
  2943  			},
  2944  			{
  2945  				overloadId: 5,
  2946  				args:       []types.T{types.T_int16},
  2947  				retType: func(parameters []types.Type) types.Type {
  2948  					return types.T_decimal128.ToType()
  2949  				},
  2950  				newOp: func() executeLogicOfOverload {
  2951  					return Oct[int16]
  2952  				},
  2953  			},
  2954  			{
  2955  				overloadId: 6,
  2956  				args:       []types.T{types.T_int32},
  2957  				retType: func(parameters []types.Type) types.Type {
  2958  					return types.T_decimal128.ToType()
  2959  				},
  2960  				newOp: func() executeLogicOfOverload {
  2961  					return Oct[int32]
  2962  				},
  2963  			},
  2964  			{
  2965  				overloadId: 7,
  2966  				args:       []types.T{types.T_int64},
  2967  				retType: func(parameters []types.Type) types.Type {
  2968  					return types.T_decimal128.ToType()
  2969  				},
  2970  				newOp: func() executeLogicOfOverload {
  2971  					return Oct[int64]
  2972  				},
  2973  			},
  2974  			{
  2975  				overloadId: 8,
  2976  				args:       []types.T{types.T_float32},
  2977  				retType: func(parameters []types.Type) types.Type {
  2978  					return types.T_decimal128.ToType()
  2979  				},
  2980  				newOp: func() executeLogicOfOverload {
  2981  					return OctFloat[float32]
  2982  				},
  2983  			},
  2984  			{
  2985  				overloadId: 9,
  2986  				args:       []types.T{types.T_float64},
  2987  				retType: func(parameters []types.Type) types.Type {
  2988  					return types.T_decimal128.ToType()
  2989  				},
  2990  				newOp: func() executeLogicOfOverload {
  2991  					return OctFloat[float64]
  2992  				},
  2993  			},
  2994  		},
  2995  	},
  2996  
  2997  	// function `PI`
  2998  	{
  2999  		functionId: PI,
  3000  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  3001  		layout:     STANDARD_FUNCTION,
  3002  		checkFn:    fixedTypeMatch,
  3003  
  3004  		Overloads: []overload{
  3005  			{
  3006  				overloadId: 0,
  3007  				args:       []types.T{},
  3008  				retType: func(parameters []types.Type) types.Type {
  3009  					return types.T_float64.ToType()
  3010  				},
  3011  				newOp: func() executeLogicOfOverload {
  3012  					return Pi
  3013  				},
  3014  			},
  3015  		},
  3016  	},
  3017  
  3018  	// function `power`
  3019  	{
  3020  		functionId: POW,
  3021  		class:      plan.Function_STRICT,
  3022  		layout:     STANDARD_FUNCTION,
  3023  		checkFn:    fixedTypeMatch,
  3024  
  3025  		Overloads: []overload{
  3026  			{
  3027  				overloadId: 0,
  3028  				args:       []types.T{types.T_float64, types.T_float64},
  3029  				retType: func(parameters []types.Type) types.Type {
  3030  					return types.T_float64.ToType()
  3031  				},
  3032  				newOp: func() executeLogicOfOverload {
  3033  					return Power
  3034  				},
  3035  			},
  3036  		},
  3037  	},
  3038  
  3039  	// function `rand`, `rand(1)`
  3040  	{
  3041  		functionId: RANDOM,
  3042  		class:      plan.Function_STRICT,
  3043  		layout:     STANDARD_FUNCTION,
  3044  		checkFn:    fixedTypeMatch,
  3045  
  3046  		Overloads: []overload{
  3047  			//{
  3048  			//	overloadId:     0,
  3049  			//	args:           []types.T{types.T_int64},
  3050  			//	cannotParallel: true,
  3051  			//	volatile:       true,
  3052  			//	retType: func(parameters []types.Type) types.Type {
  3053  			//		return types.T_float64.ToType()
  3054  			//	},
  3055  			//	newOp: func() executeLogicOfOverload {
  3056  			//		return newOpBuiltInRand().builtInRand
  3057  			//	},
  3058  			//},
  3059  
  3060  			{
  3061  				overloadId: 0,
  3062  				args:       nil,
  3063  				volatile:   true,
  3064  				retType: func(parameters []types.Type) types.Type {
  3065  					return types.T_float64.ToType()
  3066  				},
  3067  				newOp: func() executeLogicOfOverload {
  3068  					return builtInRand
  3069  				},
  3070  			},
  3071  		},
  3072  	},
  3073  
  3074  	// function `round`
  3075  	{
  3076  		functionId: ROUND,
  3077  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  3078  		layout:     STANDARD_FUNCTION,
  3079  		checkFn:    fixedTypeMatch,
  3080  
  3081  		Overloads: []overload{
  3082  			{
  3083  				overloadId: 0,
  3084  				args:       []types.T{types.T_uint64},
  3085  				retType: func(parameters []types.Type) types.Type {
  3086  					return types.T_uint64.ToType()
  3087  				},
  3088  				newOp: func() executeLogicOfOverload {
  3089  					return RoundUint64
  3090  				},
  3091  			},
  3092  			{
  3093  				overloadId: 1,
  3094  				args:       []types.T{types.T_uint64, types.T_int64},
  3095  				retType: func(parameters []types.Type) types.Type {
  3096  					return types.T_uint64.ToType()
  3097  				},
  3098  				newOp: func() executeLogicOfOverload {
  3099  					return RoundUint64
  3100  				},
  3101  			},
  3102  			{
  3103  				overloadId: 2,
  3104  				args:       []types.T{types.T_int64},
  3105  				retType: func(parameters []types.Type) types.Type {
  3106  					return types.T_int64.ToType()
  3107  				},
  3108  				newOp: func() executeLogicOfOverload {
  3109  					return RoundInt64
  3110  				},
  3111  			},
  3112  			{
  3113  				overloadId: 3,
  3114  				args:       []types.T{types.T_int64, types.T_int64},
  3115  				retType: func(parameters []types.Type) types.Type {
  3116  					return types.T_int64.ToType()
  3117  				},
  3118  				newOp: func() executeLogicOfOverload {
  3119  					return RoundInt64
  3120  				},
  3121  			},
  3122  			{
  3123  				overloadId: 4,
  3124  				args:       []types.T{types.T_float64},
  3125  				retType: func(parameters []types.Type) types.Type {
  3126  					return types.T_float64.ToType()
  3127  				},
  3128  				newOp: func() executeLogicOfOverload {
  3129  					return RoundFloat64
  3130  				},
  3131  			},
  3132  			{
  3133  				overloadId: 5,
  3134  				args:       []types.T{types.T_float64, types.T_int64},
  3135  				retType: func(parameters []types.Type) types.Type {
  3136  					return types.T_float64.ToType()
  3137  				},
  3138  				newOp: func() executeLogicOfOverload {
  3139  					return RoundFloat64
  3140  				},
  3141  			},
  3142  			{
  3143  				overloadId: 6,
  3144  				args:       []types.T{types.T_decimal64},
  3145  				retType: func(parameters []types.Type) types.Type {
  3146  					return parameters[0]
  3147  				},
  3148  				newOp: func() executeLogicOfOverload {
  3149  					return RoundDecimal64
  3150  				},
  3151  			},
  3152  			{
  3153  				overloadId: 7,
  3154  				args:       []types.T{types.T_decimal64, types.T_int64},
  3155  				retType: func(parameters []types.Type) types.Type {
  3156  					return parameters[0]
  3157  				},
  3158  				newOp: func() executeLogicOfOverload {
  3159  					return RoundDecimal64
  3160  				},
  3161  			},
  3162  			{
  3163  				overloadId: 8,
  3164  				args:       []types.T{types.T_decimal128},
  3165  				retType: func(parameters []types.Type) types.Type {
  3166  					return parameters[0]
  3167  				},
  3168  				newOp: func() executeLogicOfOverload {
  3169  					return RoundDecimal128
  3170  				},
  3171  			},
  3172  			{
  3173  				overloadId: 9,
  3174  				args:       []types.T{types.T_decimal128, types.T_int64},
  3175  				retType: func(parameters []types.Type) types.Type {
  3176  					return parameters[0]
  3177  				},
  3178  				newOp: func() executeLogicOfOverload {
  3179  					return RoundDecimal128
  3180  				},
  3181  			},
  3182  		},
  3183  	},
  3184  
  3185  	// function `sin`
  3186  	{
  3187  		functionId: SIN,
  3188  		class:      plan.Function_STRICT,
  3189  		layout:     STANDARD_FUNCTION,
  3190  		checkFn:    fixedTypeMatch,
  3191  
  3192  		Overloads: []overload{
  3193  			{
  3194  				overloadId: 0,
  3195  				args:       []types.T{types.T_float64},
  3196  				retType: func(parameters []types.Type) types.Type {
  3197  					return types.T_float64.ToType()
  3198  				},
  3199  				newOp: func() executeLogicOfOverload {
  3200  					return builtInSin
  3201  				},
  3202  			},
  3203  		},
  3204  	},
  3205  
  3206  	// function `sinh`
  3207  	{
  3208  		functionId: SINH,
  3209  		class:      plan.Function_STRICT,
  3210  		layout:     STANDARD_FUNCTION,
  3211  		checkFn:    fixedTypeMatch,
  3212  
  3213  		Overloads: []overload{
  3214  			{
  3215  				overloadId: 0,
  3216  				args:       []types.T{types.T_float64},
  3217  				retType: func(parameters []types.Type) types.Type {
  3218  					return types.T_float64.ToType()
  3219  				},
  3220  				newOp: func() executeLogicOfOverload {
  3221  					return builtInSinh
  3222  				},
  3223  			},
  3224  		},
  3225  	},
  3226  
  3227  	// function `tan`
  3228  	{
  3229  		functionId: TAN,
  3230  		class:      plan.Function_STRICT,
  3231  		layout:     STANDARD_FUNCTION,
  3232  		checkFn:    fixedTypeMatch,
  3233  
  3234  		Overloads: []overload{
  3235  			{
  3236  				overloadId: 0,
  3237  				args:       []types.T{types.T_float64},
  3238  				retType: func(parameters []types.Type) types.Type {
  3239  					return types.T_float64.ToType()
  3240  				},
  3241  				newOp: func() executeLogicOfOverload {
  3242  					return builtInTan
  3243  				},
  3244  			},
  3245  		},
  3246  	},
  3247  }
  3248  
  3249  var supportedDateAndTimeBuiltIns = []FuncNew{
  3250  	// function `convert_tz`
  3251  	{
  3252  		functionId: CONVERT_TZ,
  3253  		class:      plan.Function_STRICT,
  3254  		layout:     STANDARD_FUNCTION,
  3255  		checkFn:    fixedTypeMatch,
  3256  
  3257  		Overloads: []overload{
  3258  			{
  3259  				overloadId: 0,
  3260  				args:       []types.T{types.T_datetime, types.T_varchar, types.T_varchar},
  3261  				retType: func(parameters []types.Type) types.Type {
  3262  					return types.T_varchar.ToType()
  3263  				},
  3264  				newOp: func() executeLogicOfOverload {
  3265  					return ConvertTz
  3266  				},
  3267  			},
  3268  		},
  3269  	},
  3270  
  3271  	// function `current_date`, `curdate`
  3272  	{
  3273  		functionId: CURRENT_DATE,
  3274  		class:      plan.Function_STRICT,
  3275  		layout:     STANDARD_FUNCTION,
  3276  		checkFn:    fixedTypeMatch,
  3277  
  3278  		Overloads: []overload{
  3279  			{
  3280  				overloadId:      0,
  3281  				args:            nil,
  3282  				realTimeRelated: true,
  3283  				retType: func(parameters []types.Type) types.Type {
  3284  					return types.T_date.ToType()
  3285  				},
  3286  				newOp: func() executeLogicOfOverload {
  3287  					return CurrentDate
  3288  				},
  3289  			},
  3290  		},
  3291  	},
  3292  
  3293  	// function `current_timestamp`, `now`
  3294  	{
  3295  		functionId: CURRENT_TIMESTAMP,
  3296  		class:      plan.Function_STRICT,
  3297  		layout:     STANDARD_FUNCTION,
  3298  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
  3299  			if len(inputs) == 0 {
  3300  				return newCheckResultWithSuccess(0)
  3301  			}
  3302  			if len(inputs) == 1 && inputs[0].Oid == types.T_int64 {
  3303  				return newCheckResultWithSuccess(0)
  3304  			}
  3305  			return newCheckResultWithFailure(failedFunctionParametersWrong)
  3306  		},
  3307  
  3308  		Overloads: []overload{
  3309  			{
  3310  				overloadId:      0,
  3311  				realTimeRelated: true,
  3312  				retType: func(parameters []types.Type) types.Type {
  3313  					typ := types.T_timestamp.ToType()
  3314  					typ.Scale = 6
  3315  					return typ
  3316  				},
  3317  				newOp: func() executeLogicOfOverload {
  3318  					return builtInCurrentTimestamp
  3319  				},
  3320  			},
  3321  		},
  3322  	},
  3323  
  3324  	// function `sysdate` (execute timestamp)
  3325  	{
  3326  		functionId: SYSDATE,
  3327  		class:      plan.Function_STRICT,
  3328  		layout:     STANDARD_FUNCTION,
  3329  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
  3330  			if len(inputs) == 0 {
  3331  				return newCheckResultWithSuccess(0)
  3332  			}
  3333  			if len(inputs) == 1 && inputs[0].Oid == types.T_int64 {
  3334  				return newCheckResultWithSuccess(0)
  3335  			}
  3336  			return newCheckResultWithFailure(failedFunctionParametersWrong)
  3337  		},
  3338  
  3339  		Overloads: []overload{
  3340  			{
  3341  				overloadId:      0,
  3342  				realTimeRelated: true,
  3343  				volatile:        true,
  3344  				retType: func(parameters []types.Type) types.Type {
  3345  					typ := types.T_timestamp.ToType()
  3346  					typ.Scale = 6
  3347  					return typ
  3348  				},
  3349  				newOp: func() executeLogicOfOverload {
  3350  					return builtInSysdate
  3351  				},
  3352  			},
  3353  		},
  3354  	},
  3355  
  3356  	// function `date`
  3357  	{
  3358  		functionId: DATE,
  3359  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  3360  		layout:     STANDARD_FUNCTION,
  3361  		checkFn:    fixedTypeMatch,
  3362  
  3363  		Overloads: []overload{
  3364  			{
  3365  				overloadId: 0,
  3366  				args:       []types.T{types.T_date},
  3367  				retType: func(parameters []types.Type) types.Type {
  3368  					return types.T_date.ToType()
  3369  				},
  3370  				newOp: func() executeLogicOfOverload {
  3371  					return DateToDate
  3372  				},
  3373  			},
  3374  			{
  3375  				overloadId: 1,
  3376  				args:       []types.T{types.T_time},
  3377  				retType: func(parameters []types.Type) types.Type {
  3378  					return types.T_date.ToType()
  3379  				},
  3380  				newOp: func() executeLogicOfOverload {
  3381  					return TimeToDate
  3382  				},
  3383  			},
  3384  			{
  3385  				overloadId: 2,
  3386  				args:       []types.T{types.T_datetime},
  3387  				retType: func(parameters []types.Type) types.Type {
  3388  					return types.T_date.ToType()
  3389  				},
  3390  				newOp: func() executeLogicOfOverload {
  3391  					return DatetimeToDate
  3392  				},
  3393  			},
  3394  			{
  3395  				overloadId: 3,
  3396  				args:       []types.T{types.T_varchar},
  3397  				retType: func(parameters []types.Type) types.Type {
  3398  					return types.T_date.ToType()
  3399  				},
  3400  				newOp: func() executeLogicOfOverload {
  3401  					return DateStringToDate
  3402  				},
  3403  			},
  3404  			{
  3405  				overloadId: 4,
  3406  				args:       []types.T{types.T_char},
  3407  				retType: func(parameters []types.Type) types.Type {
  3408  					return types.T_date.ToType()
  3409  				},
  3410  				newOp: func() executeLogicOfOverload {
  3411  					return DateStringToDate
  3412  				},
  3413  			},
  3414  		},
  3415  	},
  3416  
  3417  	// function `date_add`
  3418  	{
  3419  		functionId: DATE_ADD,
  3420  		class:      plan.Function_STRICT,
  3421  		layout:     STANDARD_FUNCTION,
  3422  		checkFn:    fixedTypeMatch,
  3423  
  3424  		Overloads: []overload{
  3425  			{
  3426  				overloadId: 0,
  3427  				args:       []types.T{types.T_date, types.T_int64, types.T_int64},
  3428  				retType: func(parameters []types.Type) types.Type {
  3429  					return types.T_date.ToType()
  3430  				},
  3431  				newOp: func() executeLogicOfOverload {
  3432  					return DateAdd
  3433  				},
  3434  			},
  3435  			{
  3436  				overloadId: 1,
  3437  				args:       []types.T{types.T_datetime, types.T_int64, types.T_int64},
  3438  				retType: func(parameters []types.Type) types.Type {
  3439  					return types.T_datetime.ToType()
  3440  				},
  3441  				newOp: func() executeLogicOfOverload {
  3442  					return DatetimeAdd
  3443  				},
  3444  			},
  3445  			{
  3446  				overloadId: 2,
  3447  				args:       []types.T{types.T_varchar, types.T_int64, types.T_int64},
  3448  				retType: func(parameters []types.Type) types.Type {
  3449  					return types.T_datetime.ToType()
  3450  				},
  3451  				newOp: func() executeLogicOfOverload {
  3452  					return DateStringAdd
  3453  				},
  3454  			},
  3455  			{
  3456  				overloadId: 3,
  3457  				args:       []types.T{types.T_char, types.T_int64, types.T_int64},
  3458  				retType: func(parameters []types.Type) types.Type {
  3459  					return types.T_datetime.ToType()
  3460  				},
  3461  				newOp: func() executeLogicOfOverload {
  3462  					return DateStringAdd
  3463  				},
  3464  			},
  3465  			{
  3466  				overloadId: 4,
  3467  				args:       []types.T{types.T_timestamp, types.T_int64, types.T_int64},
  3468  				retType: func(parameters []types.Type) types.Type {
  3469  					return types.T_timestamp.ToType()
  3470  				},
  3471  				newOp: func() executeLogicOfOverload {
  3472  					return TimestampAdd
  3473  				},
  3474  			},
  3475  			{
  3476  				overloadId: 5,
  3477  				args:       []types.T{types.T_time, types.T_int64, types.T_int64},
  3478  				retType: func(parameters []types.Type) types.Type {
  3479  					return types.T_time.ToType()
  3480  				},
  3481  				newOp: func() executeLogicOfOverload {
  3482  					return TimeAdd
  3483  				},
  3484  			},
  3485  			{
  3486  				overloadId: 6,
  3487  				args:       []types.T{types.T_text, types.T_int64, types.T_int64},
  3488  				retType: func(parameters []types.Type) types.Type {
  3489  					return types.T_datetime.ToType()
  3490  				},
  3491  				newOp: func() executeLogicOfOverload {
  3492  					return DateStringAdd
  3493  				},
  3494  			},
  3495  		},
  3496  	},
  3497  
  3498  	// function `date_format`
  3499  	{
  3500  		functionId: DATE_FORMAT,
  3501  		class:      plan.Function_STRICT,
  3502  		layout:     STANDARD_FUNCTION,
  3503  		checkFn:    fixedTypeMatch,
  3504  
  3505  		Overloads: []overload{
  3506  			{
  3507  				overloadId: 0,
  3508  				args:       []types.T{types.T_datetime, types.T_varchar},
  3509  				retType: func(parameters []types.Type) types.Type {
  3510  					return types.T_varchar.ToType()
  3511  				},
  3512  				newOp: func() executeLogicOfOverload {
  3513  					return DateFormat
  3514  				},
  3515  			},
  3516  			{
  3517  				overloadId: 1,
  3518  				args:       []types.T{types.T_datetime, types.T_char},
  3519  				retType: func(parameters []types.Type) types.Type {
  3520  					return types.T_varchar.ToType()
  3521  				},
  3522  				newOp: func() executeLogicOfOverload {
  3523  					return DateFormat
  3524  				},
  3525  			},
  3526  		},
  3527  	},
  3528  
  3529  	// function `date_sub`
  3530  	{
  3531  		functionId: DATE_SUB,
  3532  		class:      plan.Function_STRICT,
  3533  		layout:     STANDARD_FUNCTION,
  3534  		checkFn:    fixedTypeMatch,
  3535  
  3536  		Overloads: []overload{
  3537  			{
  3538  				overloadId: 0,
  3539  				args:       []types.T{types.T_date, types.T_int64, types.T_int64},
  3540  				retType: func(parameters []types.Type) types.Type {
  3541  					return types.T_date.ToType()
  3542  				},
  3543  				newOp: func() executeLogicOfOverload {
  3544  					return DateSub
  3545  				},
  3546  			},
  3547  			{
  3548  				overloadId: 1,
  3549  				args:       []types.T{types.T_datetime, types.T_int64, types.T_int64},
  3550  				retType: func(parameters []types.Type) types.Type {
  3551  					return types.T_datetime.ToType()
  3552  				},
  3553  				newOp: func() executeLogicOfOverload {
  3554  					return DatetimeSub
  3555  				},
  3556  			},
  3557  			{
  3558  				overloadId: 2,
  3559  				args:       []types.T{types.T_varchar, types.T_int64, types.T_int64},
  3560  				retType: func(parameters []types.Type) types.Type {
  3561  					return types.T_datetime.ToType()
  3562  				},
  3563  				newOp: func() executeLogicOfOverload {
  3564  					return DateStringSub
  3565  				},
  3566  			},
  3567  			{
  3568  				overloadId: 3,
  3569  				args:       []types.T{types.T_char, types.T_int64, types.T_int64},
  3570  				retType: func(parameters []types.Type) types.Type {
  3571  					return types.T_datetime.ToType()
  3572  				},
  3573  				newOp: func() executeLogicOfOverload {
  3574  					return DateStringSub
  3575  				},
  3576  			},
  3577  			{
  3578  				overloadId: 4,
  3579  				args:       []types.T{types.T_timestamp, types.T_int64, types.T_int64},
  3580  				retType: func(parameters []types.Type) types.Type {
  3581  					return types.T_timestamp.ToType()
  3582  				},
  3583  				newOp: func() executeLogicOfOverload {
  3584  					return TimestampSub
  3585  				},
  3586  			},
  3587  			{
  3588  				overloadId: 5,
  3589  				args:       []types.T{types.T_text, types.T_int64, types.T_int64},
  3590  				retType: func(parameters []types.Type) types.Type {
  3591  					return types.T_datetime.ToType()
  3592  				},
  3593  				newOp: func() executeLogicOfOverload {
  3594  					return DateStringSub
  3595  				},
  3596  			},
  3597  		},
  3598  	},
  3599  
  3600  	// function `datediff`
  3601  	{
  3602  		functionId: DATEDIFF,
  3603  		class:      plan.Function_STRICT,
  3604  		layout:     STANDARD_FUNCTION,
  3605  		checkFn:    fixedTypeMatch,
  3606  
  3607  		Overloads: []overload{
  3608  			{
  3609  				overloadId: 0,
  3610  				volatile:   true, // TODO: why true.
  3611  				args:       []types.T{types.T_date, types.T_date},
  3612  				retType: func(parameters []types.Type) types.Type {
  3613  					return types.T_int64.ToType()
  3614  				},
  3615  				newOp: func() executeLogicOfOverload {
  3616  					return builtInDateDiff
  3617  				},
  3618  			},
  3619  		},
  3620  	},
  3621  
  3622  	// function `day`
  3623  	{
  3624  		functionId: DAY,
  3625  		class:      plan.Function_STRICT,
  3626  		layout:     STANDARD_FUNCTION,
  3627  		checkFn:    fixedTypeMatch,
  3628  
  3629  		Overloads: []overload{
  3630  			{
  3631  				overloadId: 0,
  3632  				args:       []types.T{types.T_date},
  3633  				retType: func(parameters []types.Type) types.Type {
  3634  					return types.T_uint8.ToType()
  3635  				},
  3636  				newOp: func() executeLogicOfOverload {
  3637  					return DateToDay
  3638  				},
  3639  			},
  3640  			{
  3641  				overloadId: 1,
  3642  				args:       []types.T{types.T_datetime},
  3643  				retType: func(parameters []types.Type) types.Type {
  3644  					return types.T_uint8.ToType()
  3645  				},
  3646  				newOp: func() executeLogicOfOverload {
  3647  					return DatetimeToDay
  3648  				},
  3649  			},
  3650  		},
  3651  	},
  3652  
  3653  	// function `day_of_year`
  3654  	{
  3655  		functionId: DAYOFYEAR,
  3656  		class:      plan.Function_STRICT,
  3657  		layout:     STANDARD_FUNCTION,
  3658  		checkFn:    fixedTypeMatch,
  3659  
  3660  		Overloads: []overload{
  3661  			{
  3662  				overloadId: 0,
  3663  				args:       []types.T{types.T_date},
  3664  				retType: func(parameters []types.Type) types.Type {
  3665  					return types.T_uint16.ToType()
  3666  				},
  3667  				newOp: func() executeLogicOfOverload {
  3668  					return DayOfYear
  3669  				},
  3670  			},
  3671  		},
  3672  	},
  3673  
  3674  	// function `from_unixtime`
  3675  	{
  3676  		functionId: FROM_UNIXTIME,
  3677  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  3678  		layout:     STANDARD_FUNCTION,
  3679  		checkFn:    fixedTypeMatch,
  3680  
  3681  		Overloads: []overload{
  3682  			{
  3683  				overloadId: 0,
  3684  				args:       []types.T{types.T_int64},
  3685  				retType: func(parameters []types.Type) types.Type {
  3686  					return types.T_datetime.ToType()
  3687  				},
  3688  				newOp: func() executeLogicOfOverload {
  3689  					return FromUnixTimeInt64
  3690  				},
  3691  			},
  3692  			{
  3693  				overloadId: 1,
  3694  				args:       []types.T{types.T_uint64},
  3695  				retType: func(parameters []types.Type) types.Type {
  3696  					return types.T_datetime.ToType()
  3697  				},
  3698  				newOp: func() executeLogicOfOverload {
  3699  					return FromUnixTimeUint64
  3700  				},
  3701  			},
  3702  			{
  3703  				overloadId: 2,
  3704  				args:       []types.T{types.T_float64},
  3705  				retType: func(parameters []types.Type) types.Type {
  3706  					return types.T_datetime.ToType()
  3707  				},
  3708  				newOp: func() executeLogicOfOverload {
  3709  					return FromUnixTimeFloat64
  3710  				},
  3711  			},
  3712  			{
  3713  				overloadId: 2,
  3714  				args:       []types.T{types.T_int64, types.T_varchar},
  3715  				retType: func(parameters []types.Type) types.Type {
  3716  					return types.T_varchar.ToType()
  3717  				},
  3718  				newOp: func() executeLogicOfOverload {
  3719  					return FromUnixTimeInt64Format
  3720  				},
  3721  			},
  3722  			{
  3723  				overloadId: 2,
  3724  				args:       []types.T{types.T_uint64, types.T_varchar},
  3725  				retType: func(parameters []types.Type) types.Type {
  3726  					return types.T_varchar.ToType()
  3727  				},
  3728  				newOp: func() executeLogicOfOverload {
  3729  					return FromUnixTimeUint64Format
  3730  				},
  3731  			},
  3732  			{
  3733  				overloadId: 2,
  3734  				args:       []types.T{types.T_float64, types.T_varchar},
  3735  				retType: func(parameters []types.Type) types.Type {
  3736  					return types.T_varchar.ToType()
  3737  				},
  3738  				newOp: func() executeLogicOfOverload {
  3739  					return FromUnixTimeFloat64Format
  3740  				},
  3741  			},
  3742  		},
  3743  	},
  3744  
  3745  	// function `hour`
  3746  	{
  3747  		functionId: HOUR,
  3748  		class:      plan.Function_STRICT,
  3749  		layout:     STANDARD_FUNCTION,
  3750  		checkFn:    fixedTypeMatch,
  3751  
  3752  		Overloads: []overload{
  3753  			{
  3754  				overloadId: 0,
  3755  				args:       []types.T{types.T_timestamp},
  3756  				retType: func(parameters []types.Type) types.Type {
  3757  					return types.T_uint8.ToType()
  3758  				},
  3759  				newOp: func() executeLogicOfOverload {
  3760  					return TimestampToHour
  3761  				},
  3762  			},
  3763  			{
  3764  				overloadId: 1,
  3765  				args:       []types.T{types.T_datetime},
  3766  				retType: func(parameters []types.Type) types.Type {
  3767  					return types.T_uint8.ToType()
  3768  				},
  3769  				newOp: func() executeLogicOfOverload {
  3770  					return DatetimeToHour
  3771  				},
  3772  			},
  3773  		},
  3774  	},
  3775  
  3776  	// function `minute`
  3777  	{
  3778  		functionId: MINUTE,
  3779  		class:      plan.Function_STRICT,
  3780  		layout:     STANDARD_FUNCTION,
  3781  		checkFn:    fixedTypeMatch,
  3782  
  3783  		Overloads: []overload{
  3784  			{
  3785  				overloadId: 0,
  3786  				args:       []types.T{types.T_timestamp},
  3787  				retType: func(parameters []types.Type) types.Type {
  3788  					return types.T_uint8.ToType()
  3789  				},
  3790  				newOp: func() executeLogicOfOverload {
  3791  					return TimestampToMinute
  3792  				},
  3793  			},
  3794  			{
  3795  				overloadId: 1,
  3796  				args:       []types.T{types.T_datetime},
  3797  				retType: func(parameters []types.Type) types.Type {
  3798  					return types.T_uint8.ToType()
  3799  				},
  3800  				newOp: func() executeLogicOfOverload {
  3801  					return DatetimeToMinute
  3802  				},
  3803  			},
  3804  		},
  3805  	},
  3806  
  3807  	// function `mo_log_date`
  3808  	{
  3809  		functionId: MO_LOG_DATE,
  3810  		class:      plan.Function_STRICT,
  3811  		layout:     STANDARD_FUNCTION,
  3812  		checkFn:    fixedTypeMatch,
  3813  
  3814  		Overloads: []overload{
  3815  			{
  3816  				overloadId: 0,
  3817  				volatile:   true,
  3818  				args:       []types.T{types.T_varchar},
  3819  				retType: func(parameters []types.Type) types.Type {
  3820  					return types.T_date.ToType()
  3821  				},
  3822  				newOp: func() executeLogicOfOverload {
  3823  					return builtInMoLogDate
  3824  				},
  3825  			},
  3826  		},
  3827  	},
  3828  
  3829  	// function `purge_log`
  3830  	{
  3831  		functionId: PURGE_LOG,
  3832  		class:      plan.Function_STRICT,
  3833  		layout:     STANDARD_FUNCTION,
  3834  		checkFn:    fixedTypeMatch,
  3835  
  3836  		Overloads: []overload{
  3837  			{
  3838  				overloadId: 0,
  3839  				volatile:   true,
  3840  				args:       []types.T{types.T_varchar, types.T_date},
  3841  				retType: func(parameters []types.Type) types.Type {
  3842  					return types.T_uint8.ToType()
  3843  				},
  3844  				newOp: func() executeLogicOfOverload {
  3845  					return builtInPurgeLog
  3846  				},
  3847  			},
  3848  		},
  3849  	},
  3850  
  3851  	// function `mo_admin_name`
  3852  	{
  3853  		functionId: MO_ADMIN_NAME,
  3854  		class:      plan.Function_STRICT,
  3855  		layout:     STANDARD_FUNCTION,
  3856  		checkFn:    fixedTypeMatch,
  3857  
  3858  		Overloads: []overload{
  3859  			{
  3860  				overloadId: 0,
  3861  				volatile:   true,
  3862  				args:       []types.T{types.T_int64},
  3863  				retType: func(parameters []types.Type) types.Type {
  3864  					return types.T_varchar.ToType()
  3865  				},
  3866  				newOp: func() executeLogicOfOverload {
  3867  					return builtInInternalGetAdminName
  3868  				},
  3869  			},
  3870  		},
  3871  	},
  3872  
  3873  	// function `mo_cu`
  3874  	{
  3875  		functionId: MO_CU,
  3876  		class:      plan.Function_STRICT,
  3877  		layout:     STANDARD_FUNCTION,
  3878  		checkFn:    fixedTypeMatch,
  3879  
  3880  		Overloads: []overload{
  3881  			{
  3882  				overloadId: 0,
  3883  				volatile:   true,
  3884  				args:       []types.T{types.T_varchar, types.T_int64},
  3885  				retType: func(parameters []types.Type) types.Type {
  3886  					return types.T_float64.ToType()
  3887  				},
  3888  				newOp: func() executeLogicOfOverload {
  3889  					return buildInMOCU
  3890  				},
  3891  			},
  3892  			{
  3893  				overloadId: 0,
  3894  				volatile:   true,
  3895  				args:       []types.T{types.T_varchar, types.T_int64, types.T_varchar},
  3896  				retType: func(parameters []types.Type) types.Type {
  3897  					return types.T_float64.ToType()
  3898  				},
  3899  				newOp: func() executeLogicOfOverload {
  3900  					return buildInMOCU
  3901  				},
  3902  			},
  3903  		},
  3904  	},
  3905  	{
  3906  		functionId: MO_CU_V1,
  3907  		class:      plan.Function_STRICT,
  3908  		layout:     STANDARD_FUNCTION,
  3909  		checkFn:    fixedTypeMatch,
  3910  
  3911  		Overloads: []overload{
  3912  			{
  3913  				overloadId: 0,
  3914  				volatile:   true,
  3915  				args:       []types.T{types.T_varchar, types.T_int64},
  3916  				retType: func(parameters []types.Type) types.Type {
  3917  					return types.T_float64.ToType()
  3918  				},
  3919  				newOp: func() executeLogicOfOverload {
  3920  					return buildInMOCUv1
  3921  				},
  3922  			},
  3923  			{
  3924  				overloadId: 0,
  3925  				volatile:   true,
  3926  				args:       []types.T{types.T_varchar, types.T_int64, types.T_varchar},
  3927  				retType: func(parameters []types.Type) types.Type {
  3928  					return types.T_float64.ToType()
  3929  				},
  3930  				newOp: func() executeLogicOfOverload {
  3931  					return buildInMOCUv1
  3932  				},
  3933  			},
  3934  		},
  3935  	},
  3936  
  3937  	// function `month`
  3938  	{
  3939  		functionId: MONTH,
  3940  		class:      plan.Function_STRICT,
  3941  		layout:     STANDARD_FUNCTION,
  3942  		checkFn:    fixedTypeMatch,
  3943  
  3944  		Overloads: []overload{
  3945  			{
  3946  				overloadId: 0,
  3947  				args:       []types.T{types.T_date},
  3948  				retType: func(parameters []types.Type) types.Type {
  3949  					return types.T_uint8.ToType()
  3950  				},
  3951  				newOp: func() executeLogicOfOverload {
  3952  					return DateToMonth
  3953  				},
  3954  			},
  3955  			{
  3956  				overloadId: 1,
  3957  				args:       []types.T{types.T_datetime},
  3958  				retType: func(parameters []types.Type) types.Type {
  3959  					return types.T_uint8.ToType()
  3960  				},
  3961  				newOp: func() executeLogicOfOverload {
  3962  					return DatetimeToMonth
  3963  				},
  3964  			},
  3965  			{
  3966  				overloadId: 2,
  3967  				args:       []types.T{types.T_varchar},
  3968  				retType: func(parameters []types.Type) types.Type {
  3969  					return types.T_uint8.ToType()
  3970  				},
  3971  				newOp: func() executeLogicOfOverload {
  3972  					return DateStringToMonth
  3973  				},
  3974  			},
  3975  		},
  3976  	},
  3977  
  3978  	// function `second`
  3979  	{
  3980  		functionId: SECOND,
  3981  		class:      plan.Function_STRICT,
  3982  		layout:     STANDARD_FUNCTION,
  3983  		checkFn:    fixedTypeMatch,
  3984  
  3985  		Overloads: []overload{
  3986  			{
  3987  				overloadId: 0,
  3988  				args:       []types.T{types.T_timestamp},
  3989  				retType: func(parameters []types.Type) types.Type {
  3990  					return types.T_uint8.ToType()
  3991  				},
  3992  				newOp: func() executeLogicOfOverload {
  3993  					return TimestampToSecond
  3994  				},
  3995  			},
  3996  			{
  3997  				overloadId: 1,
  3998  				args:       []types.T{types.T_datetime},
  3999  				retType: func(parameters []types.Type) types.Type {
  4000  					return types.T_uint8.ToType()
  4001  				},
  4002  				newOp: func() executeLogicOfOverload {
  4003  					return DatetimeToSecond
  4004  				},
  4005  			},
  4006  		},
  4007  	},
  4008  
  4009  	// function `str_to_date`, `to_date`
  4010  	{
  4011  		functionId: STR_TO_DATE,
  4012  		class:      plan.Function_STRICT,
  4013  		layout:     STANDARD_FUNCTION,
  4014  		checkFn:    fixedTypeMatch,
  4015  
  4016  		Overloads: []overload{
  4017  			{
  4018  				overloadId: 0,
  4019  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_datetime},
  4020  				retType: func(parameters []types.Type) types.Type {
  4021  					return types.T_datetime.ToType()
  4022  				},
  4023  
  4024  				newOp: func() executeLogicOfOverload {
  4025  					return builtInStrToDatetime
  4026  				},
  4027  			},
  4028  
  4029  			{
  4030  				overloadId: 1,
  4031  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_date},
  4032  				retType: func(parameters []types.Type) types.Type {
  4033  					return types.T_date.ToType()
  4034  				},
  4035  
  4036  				newOp: func() executeLogicOfOverload {
  4037  					return builtInStrToDate
  4038  				},
  4039  			},
  4040  
  4041  			{
  4042  				overloadId: 2,
  4043  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_time},
  4044  				retType: func(parameters []types.Type) types.Type {
  4045  					return types.T_time.ToType()
  4046  				},
  4047  
  4048  				newOp: func() executeLogicOfOverload {
  4049  					return builtInStrToTime
  4050  				},
  4051  			},
  4052  		},
  4053  	},
  4054  
  4055  	// function `time`
  4056  	{
  4057  		functionId: TIME,
  4058  		class:      plan.Function_STRICT,
  4059  		layout:     STANDARD_FUNCTION,
  4060  		checkFn:    fixedTypeMatch,
  4061  
  4062  		Overloads: []overload{
  4063  			{
  4064  				overloadId: 0,
  4065  				args:       []types.T{types.T_time},
  4066  				retType: func(parameters []types.Type) types.Type {
  4067  					return types.T_time.ToType()
  4068  				},
  4069  				newOp: func() executeLogicOfOverload {
  4070  					return TimeToTime
  4071  				},
  4072  			},
  4073  			{
  4074  				overloadId: 1,
  4075  				args:       []types.T{types.T_date},
  4076  				retType: func(parameters []types.Type) types.Type {
  4077  					return types.T_time.ToType()
  4078  				},
  4079  				newOp: func() executeLogicOfOverload {
  4080  					return DateToTime
  4081  				},
  4082  			},
  4083  			{
  4084  				overloadId: 2,
  4085  				args:       []types.T{types.T_datetime},
  4086  				retType: func(parameters []types.Type) types.Type {
  4087  					return types.T_time.ToType()
  4088  				},
  4089  				newOp: func() executeLogicOfOverload {
  4090  					return DatetimeToTime
  4091  				},
  4092  			},
  4093  			{
  4094  				overloadId: 3,
  4095  				args:       []types.T{types.T_int64},
  4096  				retType: func(parameters []types.Type) types.Type {
  4097  					return types.T_time.ToType()
  4098  				},
  4099  				newOp: func() executeLogicOfOverload {
  4100  					return Int64ToTime
  4101  				},
  4102  			},
  4103  			{
  4104  				overloadId: 4,
  4105  				args:       []types.T{types.T_decimal128},
  4106  				retType: func(parameters []types.Type) types.Type {
  4107  					return types.T_time.ToType()
  4108  				},
  4109  				newOp: func() executeLogicOfOverload {
  4110  					return Decimal128ToTime
  4111  				},
  4112  			},
  4113  			{
  4114  				overloadId: 5,
  4115  				args:       []types.T{types.T_varchar},
  4116  				retType: func(parameters []types.Type) types.Type {
  4117  					return types.T_time.ToType()
  4118  				},
  4119  				newOp: func() executeLogicOfOverload {
  4120  					return DateStringToTime
  4121  				},
  4122  			},
  4123  			{
  4124  				overloadId: 6,
  4125  				args:       []types.T{types.T_char},
  4126  				retType: func(parameters []types.Type) types.Type {
  4127  					return types.T_time.ToType()
  4128  				},
  4129  				newOp: func() executeLogicOfOverload {
  4130  					return DateStringToTime
  4131  				},
  4132  			},
  4133  			{
  4134  				overloadId: 7,
  4135  				args:       []types.T{types.T_text},
  4136  				retType: func(parameters []types.Type) types.Type {
  4137  					return types.T_time.ToType()
  4138  				},
  4139  				newOp: func() executeLogicOfOverload {
  4140  					return DateStringToTime
  4141  				},
  4142  			},
  4143  			{
  4144  				overloadId: 8,
  4145  				args:       []types.T{types.T_blob},
  4146  				retType: func(parameters []types.Type) types.Type {
  4147  					return types.T_time.ToType()
  4148  				},
  4149  				newOp: func() executeLogicOfOverload {
  4150  					return DateStringToTime
  4151  				},
  4152  			},
  4153  		},
  4154  	},
  4155  
  4156  	// function `timediff`
  4157  	{
  4158  		functionId: TIMEDIFF,
  4159  		class:      plan.Function_STRICT,
  4160  		layout:     STANDARD_FUNCTION,
  4161  		checkFn:    fixedTypeMatch,
  4162  
  4163  		Overloads: []overload{
  4164  			{
  4165  				overloadId: 0,
  4166  				args:       []types.T{types.T_time, types.T_time},
  4167  				retType: func(parameters []types.Type) types.Type {
  4168  					return parameters[0]
  4169  				},
  4170  				newOp: func() executeLogicOfOverload {
  4171  					return TimeDiff[types.Time]
  4172  				},
  4173  			},
  4174  			{
  4175  				overloadId: 1,
  4176  				args:       []types.T{types.T_datetime, types.T_datetime},
  4177  				retType: func(parameters []types.Type) types.Type {
  4178  					t := types.T_time.ToType()
  4179  					t.Scale = parameters[0].Scale
  4180  					return t
  4181  				},
  4182  				newOp: func() executeLogicOfOverload {
  4183  					return TimeDiff[types.Datetime]
  4184  				},
  4185  			},
  4186  		},
  4187  	},
  4188  
  4189  	// function `timestamp`
  4190  	{
  4191  		functionId: TIMESTAMP,
  4192  		class:      plan.Function_STRICT,
  4193  		layout:     STANDARD_FUNCTION,
  4194  		checkFn:    fixedTypeMatch,
  4195  
  4196  		Overloads: []overload{
  4197  			{
  4198  				overloadId: 0,
  4199  				args:       []types.T{types.T_date},
  4200  				retType: func(parameters []types.Type) types.Type {
  4201  					return types.T_timestamp.ToType()
  4202  				},
  4203  				newOp: func() executeLogicOfOverload {
  4204  					return DateToTimestamp
  4205  				},
  4206  			},
  4207  			{
  4208  				overloadId: 1,
  4209  				args:       []types.T{types.T_datetime},
  4210  				retType: func(parameters []types.Type) types.Type {
  4211  					return types.T_timestamp.ToType()
  4212  				},
  4213  				newOp: func() executeLogicOfOverload {
  4214  					return DatetimeToTimestamp
  4215  				},
  4216  			},
  4217  			{
  4218  				overloadId: 2,
  4219  				args:       []types.T{types.T_timestamp},
  4220  				retType: func(parameters []types.Type) types.Type {
  4221  					return types.T_timestamp.ToType()
  4222  				},
  4223  				newOp: func() executeLogicOfOverload {
  4224  					return TimestampToTimestamp
  4225  				},
  4226  			},
  4227  			{
  4228  				overloadId: 3,
  4229  				args:       []types.T{types.T_varchar},
  4230  				retType: func(parameters []types.Type) types.Type {
  4231  					return types.T_timestamp.ToType()
  4232  				},
  4233  				newOp: func() executeLogicOfOverload {
  4234  					return DateStringToTimestamp
  4235  				},
  4236  			},
  4237  			{
  4238  				overloadId: 4,
  4239  				args:       []types.T{types.T_char},
  4240  				retType: func(parameters []types.Type) types.Type {
  4241  					return types.T_timestamp.ToType()
  4242  				},
  4243  				newOp: func() executeLogicOfOverload {
  4244  					return DateStringToTimestamp
  4245  				},
  4246  			},
  4247  		},
  4248  	},
  4249  
  4250  	// function `timestampdiff`
  4251  	{
  4252  		functionId: TIMESTAMPDIFF,
  4253  		class:      plan.Function_STRICT,
  4254  		layout:     STANDARD_FUNCTION,
  4255  		checkFn:    fixedTypeMatch,
  4256  
  4257  		Overloads: []overload{
  4258  			{
  4259  				overloadId: 0,
  4260  				args:       []types.T{types.T_varchar, types.T_datetime, types.T_datetime},
  4261  				retType: func(parameters []types.Type) types.Type {
  4262  					return types.T_int64.ToType()
  4263  				},
  4264  				newOp: func() executeLogicOfOverload {
  4265  					return TimestampDiff
  4266  				},
  4267  			},
  4268  		},
  4269  	},
  4270  
  4271  	// function `to_days`
  4272  	{
  4273  		functionId: TO_DAYS,
  4274  		class:      plan.Function_STRICT,
  4275  		layout:     STANDARD_FUNCTION,
  4276  		checkFn:    fixedTypeMatch,
  4277  
  4278  		Overloads: []overload{
  4279  			{
  4280  				overloadId: 0,
  4281  				args:       []types.T{types.T_datetime},
  4282  				retType: func(parameters []types.Type) types.Type {
  4283  					return types.T_int64.ToType()
  4284  				},
  4285  				newOp: func() executeLogicOfOverload {
  4286  					return builtInToDays
  4287  				},
  4288  			},
  4289  		},
  4290  	},
  4291  
  4292  	// function `to_seconds`
  4293  	{
  4294  		functionId: TO_SECONDS,
  4295  		class:      plan.Function_STRICT,
  4296  		layout:     STANDARD_FUNCTION,
  4297  		checkFn:    fixedTypeMatch,
  4298  
  4299  		Overloads: []overload{
  4300  			{
  4301  				overloadId: 0,
  4302  				args:       []types.T{types.T_datetime},
  4303  				retType: func(parameters []types.Type) types.Type {
  4304  					return types.T_int64.ToType()
  4305  				},
  4306  				newOp: func() executeLogicOfOverload {
  4307  					return builtInToSeconds
  4308  				},
  4309  			},
  4310  		},
  4311  	},
  4312  
  4313  	// function `unix_timestamp`
  4314  	{
  4315  		functionId: UNIX_TIMESTAMP,
  4316  		class:      plan.Function_STRICT,
  4317  		layout:     STANDARD_FUNCTION,
  4318  		checkFn:    fixedTypeMatch,
  4319  
  4320  		Overloads: []overload{
  4321  			{
  4322  				overloadId: 0,
  4323  				volatile:   true,
  4324  				args:       []types.T{},
  4325  				retType: func(parameters []types.Type) types.Type {
  4326  					return types.T_int64.ToType()
  4327  				},
  4328  				newOp: func() executeLogicOfOverload {
  4329  					return builtInUnixTimestamp
  4330  				},
  4331  			},
  4332  			{
  4333  				overloadId: 1,
  4334  				volatile:   true,
  4335  				args:       []types.T{types.T_timestamp},
  4336  				retType: func(parameters []types.Type) types.Type {
  4337  					return types.T_int64.ToType()
  4338  				},
  4339  				newOp: func() executeLogicOfOverload {
  4340  					return builtInUnixTimestamp
  4341  				},
  4342  			},
  4343  			{
  4344  				overloadId: 2,
  4345  				volatile:   true,
  4346  				args:       []types.T{types.T_varchar, types.T_int64},
  4347  				retType: func(parameters []types.Type) types.Type {
  4348  					return types.T_int64.ToType()
  4349  				},
  4350  				newOp: func() executeLogicOfOverload {
  4351  					return builtInUnixTimestampVarcharToInt64
  4352  				},
  4353  			},
  4354  			{
  4355  				overloadId: 3,
  4356  				volatile:   true,
  4357  				args:       []types.T{types.T_varchar, types.T_decimal128},
  4358  				retType: func(parameters []types.Type) types.Type {
  4359  					return types.New(types.T_decimal128, 38, 6)
  4360  				},
  4361  				newOp: func() executeLogicOfOverload {
  4362  					return builtInUnixTimestampVarcharToDecimal128
  4363  				},
  4364  			},
  4365  		},
  4366  	},
  4367  
  4368  	// function `utc_timestamp`
  4369  	{
  4370  		functionId: UTC_TIMESTAMP,
  4371  		class:      plan.Function_STRICT,
  4372  		layout:     STANDARD_FUNCTION,
  4373  		checkFn:    fixedTypeMatch,
  4374  
  4375  		Overloads: []overload{
  4376  			{
  4377  				overloadId: 0,
  4378  				args:       []types.T{},
  4379  				retType: func(parameters []types.Type) types.Type {
  4380  					return types.T_datetime.ToType()
  4381  				},
  4382  				newOp: func() executeLogicOfOverload {
  4383  					return UTCTimestamp
  4384  				},
  4385  			},
  4386  		},
  4387  	},
  4388  
  4389  	// function `week`
  4390  	{
  4391  		functionId: WEEK,
  4392  		class:      plan.Function_STRICT,
  4393  		layout:     STANDARD_FUNCTION,
  4394  		checkFn:    fixedTypeMatch,
  4395  
  4396  		Overloads: []overload{
  4397  			{
  4398  				overloadId: 0,
  4399  				args:       []types.T{types.T_date},
  4400  				retType: func(parameters []types.Type) types.Type {
  4401  					return types.T_uint8.ToType()
  4402  				},
  4403  				newOp: func() executeLogicOfOverload {
  4404  					return DateToWeek
  4405  				},
  4406  			},
  4407  			{
  4408  				overloadId: 1,
  4409  				args:       []types.T{types.T_datetime},
  4410  				retType: func(parameters []types.Type) types.Type {
  4411  					return types.T_uint8.ToType()
  4412  				},
  4413  				newOp: func() executeLogicOfOverload {
  4414  					return DatetimeToWeek
  4415  				},
  4416  			},
  4417  		},
  4418  	},
  4419  
  4420  	// function `weekday`
  4421  	{
  4422  		functionId: WEEKDAY,
  4423  		class:      plan.Function_STRICT,
  4424  		layout:     STANDARD_FUNCTION,
  4425  		checkFn:    fixedTypeMatch,
  4426  
  4427  		Overloads: []overload{
  4428  			{
  4429  				overloadId: 0,
  4430  				args:       []types.T{types.T_date},
  4431  				retType: func(parameters []types.Type) types.Type {
  4432  					return types.T_int64.ToType()
  4433  				},
  4434  				newOp: func() executeLogicOfOverload {
  4435  					return DateToWeekday
  4436  				},
  4437  			},
  4438  			{
  4439  				overloadId: 1,
  4440  				args:       []types.T{types.T_datetime},
  4441  				retType: func(parameters []types.Type) types.Type {
  4442  					return types.T_int64.ToType()
  4443  				},
  4444  				newOp: func() executeLogicOfOverload {
  4445  					return DatetimeToWeekday
  4446  				},
  4447  			},
  4448  		},
  4449  	},
  4450  
  4451  	// function `year`
  4452  	{
  4453  		functionId: YEAR,
  4454  		class:      plan.Function_STRICT | plan.Function_ZONEMAPPABLE,
  4455  		layout:     STANDARD_FUNCTION,
  4456  		checkFn:    fixedTypeMatch,
  4457  
  4458  		Overloads: []overload{
  4459  			{
  4460  				overloadId: 0,
  4461  				args:       []types.T{types.T_date},
  4462  				retType: func(parameters []types.Type) types.Type {
  4463  					return types.T_int64.ToType()
  4464  				},
  4465  				newOp: func() executeLogicOfOverload {
  4466  					return DateToYear
  4467  				},
  4468  			},
  4469  			{
  4470  				overloadId: 1,
  4471  				args:       []types.T{types.T_datetime},
  4472  				retType: func(parameters []types.Type) types.Type {
  4473  					return types.T_int64.ToType()
  4474  				},
  4475  				newOp: func() executeLogicOfOverload {
  4476  					return DatetimeToYear
  4477  				},
  4478  			},
  4479  			{
  4480  				overloadId: 2,
  4481  				args:       []types.T{types.T_varchar},
  4482  				retType: func(parameters []types.Type) types.Type {
  4483  					return types.T_int64.ToType()
  4484  				},
  4485  				newOp: func() executeLogicOfOverload {
  4486  					return DateStringToYear
  4487  				},
  4488  			},
  4489  		},
  4490  	},
  4491  }
  4492  
  4493  var supportedControlBuiltIns = []FuncNew{
  4494  	// function `add_fault_point`
  4495  	{
  4496  		functionId: ADD_FAULT_POINT,
  4497  		class:      plan.Function_STRICT,
  4498  		layout:     STANDARD_FUNCTION,
  4499  		checkFn:    fixedTypeMatch,
  4500  
  4501  		Overloads: []overload{
  4502  			{
  4503  				overloadId: 0,
  4504  				volatile:   true,
  4505  				args:       []types.T{types.T_varchar, types.T_varchar, types.T_varchar, types.T_int64, types.T_varchar},
  4506  				retType: func(parameters []types.Type) types.Type {
  4507  					return types.T_bool.ToType()
  4508  				},
  4509  				newOp: func() executeLogicOfOverload {
  4510  					return AddFaultPoint
  4511  				},
  4512  			},
  4513  		},
  4514  	},
  4515  
  4516  	// function `disable_fault_injection`
  4517  	{
  4518  		functionId: DISABLE_FAULT_INJECTION,
  4519  		class:      plan.Function_INTERNAL,
  4520  		layout:     STANDARD_FUNCTION,
  4521  		checkFn:    fixedTypeMatch,
  4522  
  4523  		Overloads: []overload{
  4524  			{
  4525  				overloadId: 0,
  4526  				args:       []types.T{},
  4527  				retType: func(parameters []types.Type) types.Type {
  4528  					return types.T_bool.ToType()
  4529  				},
  4530  				newOp: func() executeLogicOfOverload {
  4531  					return DisableFaultInjection
  4532  				},
  4533  			},
  4534  		},
  4535  	},
  4536  
  4537  	// function `enable_fault_injection`
  4538  	{
  4539  		functionId: ENABLE_FAULT_INJECTION,
  4540  		class:      plan.Function_INTERNAL,
  4541  		layout:     STANDARD_FUNCTION,
  4542  		checkFn:    fixedTypeMatch,
  4543  
  4544  		Overloads: []overload{
  4545  			{
  4546  				overloadId: 0,
  4547  				args:       []types.T{},
  4548  				retType: func(parameters []types.Type) types.Type {
  4549  					return types.T_bool.ToType()
  4550  				},
  4551  				newOp: func() executeLogicOfOverload {
  4552  					return EnableFaultInjection
  4553  				},
  4554  			},
  4555  		},
  4556  	},
  4557  
  4558  	// function `mo_ctl`
  4559  	{
  4560  		functionId: MO_CTL,
  4561  		class:      plan.Function_STRICT,
  4562  		layout:     STANDARD_FUNCTION,
  4563  		checkFn:    fixedTypeMatch,
  4564  
  4565  		Overloads: []overload{
  4566  			{
  4567  				overloadId:      0,
  4568  				args:            []types.T{types.T_varchar, types.T_varchar, types.T_varchar},
  4569  				volatile:        true,
  4570  				realTimeRelated: true,
  4571  				retType: func(parameters []types.Type) types.Type {
  4572  					return types.T_varchar.ToType()
  4573  				},
  4574  				newOp: func() executeLogicOfOverload {
  4575  					return ctl.MoCtl
  4576  				},
  4577  			},
  4578  		},
  4579  	},
  4580  
  4581  	// function `mo_enable_memory_usage_detail`
  4582  	{
  4583  		functionId: MO_ENABLE_MEMORY_USAGE_DETAIL,
  4584  		class:      plan.Function_INTERNAL,
  4585  		layout:     STANDARD_FUNCTION,
  4586  		checkFn:    fixedTypeMatch,
  4587  
  4588  		Overloads: []overload{
  4589  			{
  4590  				overloadId: 0,
  4591  				volatile:   true,
  4592  				args:       []types.T{types.T_varchar},
  4593  				retType: func(parameters []types.Type) types.Type {
  4594  					return types.T_varchar.ToType()
  4595  				},
  4596  				newOp: func() executeLogicOfOverload {
  4597  					return MoEnableMemUsageDetail
  4598  				},
  4599  			},
  4600  		},
  4601  	},
  4602  
  4603  	// function `mo_disable_memory_usage_detail`
  4604  	{
  4605  		functionId: MO_DISABLE_MEMORY_USAGE_DETAIL,
  4606  		class:      plan.Function_INTERNAL,
  4607  		layout:     STANDARD_FUNCTION,
  4608  		checkFn:    fixedTypeMatch,
  4609  
  4610  		Overloads: []overload{
  4611  			{
  4612  				overloadId: 0,
  4613  				volatile:   true,
  4614  				args:       []types.T{types.T_varchar},
  4615  				retType: func(parameters []types.Type) types.Type {
  4616  					return types.T_varchar.ToType()
  4617  				},
  4618  				newOp: func() executeLogicOfOverload {
  4619  					return MoDisableMemUsageDetail
  4620  				},
  4621  			},
  4622  		},
  4623  	},
  4624  
  4625  	// function `remove_fault_point`
  4626  	{
  4627  		functionId: REMOVE_FAULT_POINT,
  4628  		class:      plan.Function_INTERNAL,
  4629  		layout:     STANDARD_FUNCTION,
  4630  		checkFn:    fixedTypeMatch,
  4631  
  4632  		Overloads: []overload{
  4633  			{
  4634  				overloadId: 0,
  4635  				volatile:   true,
  4636  				args:       []types.T{types.T_varchar},
  4637  				retType: func(parameters []types.Type) types.Type {
  4638  					return types.T_bool.ToType()
  4639  				},
  4640  				newOp: func() executeLogicOfOverload {
  4641  					return RemoveFaultPoint
  4642  				},
  4643  			},
  4644  		},
  4645  	},
  4646  
  4647  	// function `sleep`
  4648  	{
  4649  		functionId: SLEEP,
  4650  		class:      plan.Function_STRICT,
  4651  		layout:     STANDARD_FUNCTION,
  4652  		checkFn:    fixedTypeMatch,
  4653  
  4654  		Overloads: []overload{
  4655  			{
  4656  				overloadId:      0,
  4657  				args:            []types.T{types.T_uint64},
  4658  				volatile:        true,
  4659  				realTimeRelated: true,
  4660  				retType: func(parameters []types.Type) types.Type {
  4661  					return types.T_uint8.ToType()
  4662  				},
  4663  				newOp: func() executeLogicOfOverload {
  4664  					return Sleep[uint64]
  4665  				},
  4666  			},
  4667  			{
  4668  				overloadId:      0,
  4669  				args:            []types.T{types.T_float64},
  4670  				volatile:        true,
  4671  				realTimeRelated: true,
  4672  				retType: func(parameter []types.Type) types.Type {
  4673  					return types.T_uint8.ToType()
  4674  				},
  4675  				newOp: func() executeLogicOfOverload {
  4676  					return Sleep[float64]
  4677  				},
  4678  			},
  4679  		},
  4680  	},
  4681  
  4682  	// function `trigger_fault_point`
  4683  	{
  4684  		functionId: TRIGGER_FAULT_POINT,
  4685  		class:      plan.Function_INTERNAL,
  4686  		layout:     STANDARD_FUNCTION,
  4687  		checkFn:    fixedTypeMatch,
  4688  
  4689  		Overloads: []overload{
  4690  			{
  4691  				overloadId:      0,
  4692  				args:            []types.T{types.T_varchar},
  4693  				volatile:        true,
  4694  				realTimeRelated: true,
  4695  				retType: func(parameters []types.Type) types.Type {
  4696  					return types.T_int64.ToType()
  4697  				},
  4698  				newOp: func() executeLogicOfOverload {
  4699  					return TriggerFaultPoint
  4700  				},
  4701  			},
  4702  		},
  4703  	},
  4704  }
  4705  
  4706  var supportedOthersBuiltIns = []FuncNew{
  4707  	// function `build_version`
  4708  	{
  4709  		functionId: BUILD_VERSION,
  4710  		class:      plan.Function_STRICT,
  4711  		layout:     STANDARD_FUNCTION,
  4712  		checkFn:    fixedTypeMatch,
  4713  
  4714  		Overloads: []overload{
  4715  			{
  4716  				overloadId:      0,
  4717  				args:            nil,
  4718  				realTimeRelated: true,
  4719  				retType: func(parameters []types.Type) types.Type {
  4720  					return types.T_timestamp.ToType()
  4721  				},
  4722  				newOp: func() executeLogicOfOverload {
  4723  					return BuildVersion
  4724  				},
  4725  			},
  4726  		},
  4727  	},
  4728  
  4729  	// function `charset`
  4730  	{
  4731  		functionId: CHARSET,
  4732  		class:      plan.Function_STRICT,
  4733  		layout:     STANDARD_FUNCTION,
  4734  		checkFn:    fixedTypeMatch,
  4735  
  4736  		Overloads: []overload{
  4737  			{
  4738  				overloadId:      0,
  4739  				args:            []types.T{types.T_varchar},
  4740  				volatile:        true,
  4741  				realTimeRelated: true,
  4742  				retType: func(parameters []types.Type) types.Type {
  4743  					return types.T_varchar.ToType()
  4744  				},
  4745  				newOp: func() executeLogicOfOverload {
  4746  					return Charset
  4747  				},
  4748  			},
  4749  		},
  4750  	},
  4751  
  4752  	// function `collation`
  4753  	{
  4754  		functionId: COLLATION,
  4755  		class:      plan.Function_STRICT,
  4756  		layout:     STANDARD_FUNCTION,
  4757  		checkFn:    fixedTypeMatch,
  4758  
  4759  		Overloads: []overload{
  4760  			{
  4761  				overloadId:      0,
  4762  				args:            []types.T{types.T_varchar},
  4763  				volatile:        true,
  4764  				realTimeRelated: true,
  4765  				retType: func(parameters []types.Type) types.Type {
  4766  					return types.T_varchar.ToType()
  4767  				},
  4768  				newOp: func() executeLogicOfOverload {
  4769  					return Collation
  4770  				},
  4771  			},
  4772  		},
  4773  	},
  4774  
  4775  	// function `connection_id`
  4776  	{
  4777  		functionId: CONNECTION_ID,
  4778  		class:      plan.Function_STRICT,
  4779  		layout:     STANDARD_FUNCTION,
  4780  		checkFn:    fixedTypeMatch,
  4781  
  4782  		Overloads: []overload{
  4783  			{
  4784  				overloadId:      0,
  4785  				args:            []types.T{},
  4786  				volatile:        true,
  4787  				realTimeRelated: true,
  4788  				retType: func(parameters []types.Type) types.Type {
  4789  					return types.T_uint64.ToType()
  4790  				},
  4791  				newOp: func() executeLogicOfOverload {
  4792  					return ConnectionID
  4793  				},
  4794  			},
  4795  		},
  4796  	},
  4797  
  4798  	// function `current_account_id`
  4799  	{
  4800  		functionId: CURRENT_ACCOUNT_ID,
  4801  		class:      plan.Function_STRICT,
  4802  		layout:     STANDARD_FUNCTION,
  4803  		checkFn:    fixedTypeMatch,
  4804  
  4805  		Overloads: []overload{
  4806  			{
  4807  				overloadId:      0,
  4808  				args:            []types.T{},
  4809  				volatile:        true,
  4810  				realTimeRelated: true,
  4811  				retType: func(parameters []types.Type) types.Type {
  4812  					return types.T_uint32.ToType()
  4813  				},
  4814  				newOp: func() executeLogicOfOverload {
  4815  					return builtInCurrentAccountID
  4816  				},
  4817  			},
  4818  		},
  4819  	},
  4820  
  4821  	// function `current_account_name`
  4822  	{
  4823  		functionId: CURRENT_ACCOUNT_NAME,
  4824  		class:      plan.Function_STRICT,
  4825  		layout:     STANDARD_FUNCTION,
  4826  		checkFn:    fixedTypeMatch,
  4827  
  4828  		Overloads: []overload{
  4829  			{
  4830  				overloadId:      0,
  4831  				args:            []types.T{},
  4832  				volatile:        true,
  4833  				realTimeRelated: true,
  4834  				retType: func(parameters []types.Type) types.Type {
  4835  					return types.T_varchar.ToType()
  4836  				},
  4837  				newOp: func() executeLogicOfOverload {
  4838  					return builtInCurrentAccountName
  4839  				},
  4840  			},
  4841  		},
  4842  	},
  4843  
  4844  	// function `current_role`
  4845  	{
  4846  		functionId: CURRENT_ROLE,
  4847  		class:      plan.Function_STRICT,
  4848  		layout:     STANDARD_FUNCTION,
  4849  		checkFn:    fixedTypeMatch,
  4850  
  4851  		Overloads: []overload{
  4852  			{
  4853  				overloadId:      0,
  4854  				args:            []types.T{},
  4855  				volatile:        true,
  4856  				realTimeRelated: true,
  4857  				retType: func(parameters []types.Type) types.Type {
  4858  					return types.T_varchar.ToType()
  4859  				},
  4860  				newOp: func() executeLogicOfOverload {
  4861  					return builtInCurrentRole
  4862  				},
  4863  			},
  4864  		},
  4865  	},
  4866  
  4867  	// function `current_role_id`
  4868  	{
  4869  		functionId: CURRENT_ROLE_ID,
  4870  		class:      plan.Function_STRICT,
  4871  		layout:     STANDARD_FUNCTION,
  4872  		checkFn:    fixedTypeMatch,
  4873  
  4874  		Overloads: []overload{
  4875  			{
  4876  				overloadId:      0,
  4877  				args:            []types.T{},
  4878  				volatile:        true,
  4879  				realTimeRelated: true,
  4880  				retType: func(parameters []types.Type) types.Type {
  4881  					return types.T_uint32.ToType()
  4882  				},
  4883  				newOp: func() executeLogicOfOverload {
  4884  					return builtInCurrentRoleID
  4885  				},
  4886  			},
  4887  		},
  4888  	},
  4889  
  4890  	// function `current_user_id`
  4891  	{
  4892  		functionId: CURRENT_USER_ID,
  4893  		class:      plan.Function_STRICT,
  4894  		layout:     STANDARD_FUNCTION,
  4895  		checkFn:    fixedTypeMatch,
  4896  
  4897  		Overloads: []overload{
  4898  			{
  4899  				overloadId:      0,
  4900  				args:            []types.T{},
  4901  				volatile:        true,
  4902  				realTimeRelated: true,
  4903  				retType: func(parameters []types.Type) types.Type {
  4904  					return types.T_uint32.ToType()
  4905  				},
  4906  				newOp: func() executeLogicOfOverload {
  4907  					return builtInCurrentUserID
  4908  				},
  4909  			},
  4910  		},
  4911  	},
  4912  
  4913  	// function `current_role_name`
  4914  	{
  4915  		functionId: CURRENT_ROLE_NAME,
  4916  		class:      plan.Function_STRICT,
  4917  		layout:     STANDARD_FUNCTION,
  4918  		checkFn:    fixedTypeMatch,
  4919  
  4920  		Overloads: []overload{
  4921  			{
  4922  				overloadId:      0,
  4923  				args:            []types.T{},
  4924  				volatile:        true,
  4925  				realTimeRelated: true,
  4926  				retType: func(parameters []types.Type) types.Type {
  4927  					return types.T_varchar.ToType()
  4928  				},
  4929  				newOp: func() executeLogicOfOverload {
  4930  					return builtInCurrentRoleName
  4931  				},
  4932  			},
  4933  		},
  4934  	},
  4935  
  4936  	// function `current_user_name`
  4937  	{
  4938  		functionId: CURRENT_USER_NAME,
  4939  		class:      plan.Function_STRICT,
  4940  		layout:     STANDARD_FUNCTION,
  4941  		checkFn:    fixedTypeMatch,
  4942  
  4943  		Overloads: []overload{
  4944  			{
  4945  				overloadId:      0,
  4946  				args:            []types.T{},
  4947  				volatile:        true,
  4948  				realTimeRelated: true,
  4949  				retType: func(parameters []types.Type) types.Type {
  4950  					return types.T_varchar.ToType()
  4951  				},
  4952  				newOp: func() executeLogicOfOverload {
  4953  					return builtInCurrentUserName
  4954  				},
  4955  			},
  4956  		},
  4957  	},
  4958  
  4959  	// function `Database`, `schema`
  4960  	{
  4961  		functionId: DATABASE,
  4962  		class:      plan.Function_STRICT,
  4963  		layout:     STANDARD_FUNCTION,
  4964  		checkFn:    fixedTypeMatch,
  4965  
  4966  		Overloads: []overload{
  4967  			{
  4968  				overloadId:      0,
  4969  				args:            nil,
  4970  				volatile:        true,
  4971  				realTimeRelated: true,
  4972  				retType: func(parameters []types.Type) types.Type {
  4973  					return types.T_varchar.ToType()
  4974  				},
  4975  				newOp: func() executeLogicOfOverload {
  4976  					return builtInDatabase
  4977  				},
  4978  			},
  4979  		},
  4980  	},
  4981  
  4982  	// function `found_rows`
  4983  	{
  4984  		functionId: FOUND_ROWS,
  4985  		class:      plan.Function_STRICT,
  4986  		layout:     STANDARD_FUNCTION,
  4987  		checkFn:    fixedTypeMatch,
  4988  
  4989  		Overloads: []overload{
  4990  			{
  4991  				overloadId: 0,
  4992  				args:       []types.T{},
  4993  				volatile:   true,
  4994  				retType: func(parameters []types.Type) types.Type {
  4995  					return types.T_uint64.ToType()
  4996  				},
  4997  				newOp: func() executeLogicOfOverload {
  4998  					return FoundRows
  4999  				},
  5000  			},
  5001  		},
  5002  	},
  5003  
  5004  	// function `git_version`
  5005  	{
  5006  		functionId: GIT_VERSION,
  5007  		class:      plan.Function_STRICT,
  5008  		layout:     STANDARD_FUNCTION,
  5009  		checkFn:    fixedTypeMatch,
  5010  
  5011  		Overloads: []overload{
  5012  			{
  5013  				overloadId:      0,
  5014  				args:            nil,
  5015  				realTimeRelated: true,
  5016  				retType: func(parameters []types.Type) types.Type {
  5017  					return types.T_varchar.ToType()
  5018  				},
  5019  				newOp: func() executeLogicOfOverload {
  5020  					return GitVersion
  5021  				},
  5022  			},
  5023  		},
  5024  	},
  5025  
  5026  	// function `hash_value`
  5027  	// XXX may be used for hash bucket splitting
  5028  	{
  5029  		functionId: HASH,
  5030  		class:      plan.Function_STRICT,
  5031  		layout:     STANDARD_FUNCTION,
  5032  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
  5033  			if len(inputs) > 0 {
  5034  				return newCheckResultWithSuccess(0)
  5035  			}
  5036  			return newCheckResultWithFailure(failedFunctionParametersWrong)
  5037  		},
  5038  
  5039  		Overloads: []overload{
  5040  			{
  5041  				overloadId: 0,
  5042  				retType: func(parameters []types.Type) types.Type {
  5043  					return types.T_int64.ToType()
  5044  				},
  5045  				newOp: func() executeLogicOfOverload {
  5046  					return builtInHash
  5047  				},
  5048  			},
  5049  		},
  5050  	},
  5051  
  5052  	// function `icu_version`
  5053  	{
  5054  		functionId: ICULIBVERSION,
  5055  		class:      plan.Function_STRICT,
  5056  		layout:     STANDARD_FUNCTION,
  5057  		checkFn:    fixedTypeMatch,
  5058  
  5059  		Overloads: []overload{
  5060  			{
  5061  				overloadId: 0,
  5062  				args:       []types.T{},
  5063  				retType: func(parameters []types.Type) types.Type {
  5064  					return types.T_varchar.ToType()
  5065  				},
  5066  				newOp: func() executeLogicOfOverload {
  5067  					return ICULIBVersion
  5068  				},
  5069  			},
  5070  		},
  5071  	},
  5072  
  5073  	// function `if`, `iff`
  5074  	{
  5075  		functionId: IFF,
  5076  		class:      plan.Function_NONE,
  5077  		layout:     STANDARD_FUNCTION,
  5078  		checkFn:    iffCheck,
  5079  
  5080  		Overloads: []overload{
  5081  			{
  5082  				overloadId: 0,
  5083  				retType: func(parameters []types.Type) types.Type {
  5084  					return parameters[1]
  5085  				},
  5086  				newOp: func() executeLogicOfOverload {
  5087  					return iffFn
  5088  				},
  5089  			},
  5090  		},
  5091  	},
  5092  
  5093  	// function `internal_auto_increment`
  5094  	// 'internal_auto_increment' is used to obtain the current auto_increment column value of the table under the specified database
  5095  	{
  5096  		functionId: INTERNAL_AUTO_INCREMENT,
  5097  		class:      plan.Function_STRICT,
  5098  		layout:     STANDARD_FUNCTION,
  5099  		checkFn:    fixedTypeMatch,
  5100  
  5101  		Overloads: []overload{
  5102  			{
  5103  				overloadId: 0,
  5104  				volatile:   true,
  5105  				args:       []types.T{types.T_varchar, types.T_varchar},
  5106  				retType: func(parameters []types.Type) types.Type {
  5107  					return types.T_uint64.ToType()
  5108  				},
  5109  				newOp: func() executeLogicOfOverload {
  5110  					return builtInInternalAutoIncrement
  5111  				},
  5112  			},
  5113  		},
  5114  	},
  5115  
  5116  	// function `internal_char_length`
  5117  	{
  5118  		functionId: INTERNAL_CHAR_LENGTH,
  5119  		class:      plan.Function_STRICT,
  5120  		layout:     STANDARD_FUNCTION,
  5121  		checkFn:    fixedTypeMatch,
  5122  
  5123  		Overloads: []overload{
  5124  			{
  5125  				overloadId: 0,
  5126  				volatile:   true,
  5127  				args:       []types.T{types.T_varchar},
  5128  				retType: func(parameters []types.Type) types.Type {
  5129  					return types.T_int64.ToType()
  5130  				},
  5131  				newOp: func() executeLogicOfOverload {
  5132  					return builtInInternalCharLength
  5133  				},
  5134  			},
  5135  		},
  5136  	},
  5137  
  5138  	// function `internal_char_size`
  5139  	{
  5140  		functionId: INTERNAL_CHAR_SIZE,
  5141  		class:      plan.Function_STRICT,
  5142  		layout:     STANDARD_FUNCTION,
  5143  		checkFn:    fixedTypeMatch,
  5144  
  5145  		Overloads: []overload{
  5146  			{
  5147  				overloadId: 0,
  5148  				volatile:   true,
  5149  				args:       []types.T{types.T_varchar},
  5150  				retType: func(parameters []types.Type) types.Type {
  5151  					return types.T_int64.ToType()
  5152  				},
  5153  				newOp: func() executeLogicOfOverload {
  5154  					return builtInInternalCharSize
  5155  				},
  5156  			},
  5157  		},
  5158  	},
  5159  
  5160  	// function `internal_column_character_set`
  5161  	{
  5162  		functionId: INTERNAL_COLUMN_CHARACTER_SET,
  5163  		class:      plan.Function_STRICT,
  5164  		layout:     STANDARD_FUNCTION,
  5165  		checkFn:    fixedTypeMatch,
  5166  
  5167  		Overloads: []overload{
  5168  			{
  5169  				overloadId: 0,
  5170  				volatile:   true,
  5171  				args:       []types.T{types.T_varchar},
  5172  				retType: func(parameters []types.Type) types.Type {
  5173  					return types.T_int64.ToType()
  5174  				},
  5175  				newOp: func() executeLogicOfOverload {
  5176  					return builtInInternalCharacterSet
  5177  				},
  5178  			},
  5179  		},
  5180  	},
  5181  
  5182  	// function `internal_datetime_scale`
  5183  	{
  5184  		functionId: INTERNAL_DATETIME_SCALE,
  5185  		class:      plan.Function_STRICT,
  5186  		layout:     STANDARD_FUNCTION,
  5187  		checkFn:    fixedTypeMatch,
  5188  
  5189  		Overloads: []overload{
  5190  			{
  5191  				overloadId: 0,
  5192  				volatile:   true,
  5193  				args:       []types.T{types.T_varchar},
  5194  				retType: func(parameters []types.Type) types.Type {
  5195  					return types.T_int64.ToType()
  5196  				},
  5197  				newOp: func() executeLogicOfOverload {
  5198  					return builtInInternalDatetimeScale
  5199  				},
  5200  			},
  5201  		},
  5202  	},
  5203  
  5204  	// function `internal_numeric_precision`
  5205  	{
  5206  		functionId: INTERNAL_NUMERIC_PRECISION,
  5207  		class:      plan.Function_STRICT,
  5208  		layout:     STANDARD_FUNCTION,
  5209  		checkFn:    fixedTypeMatch,
  5210  
  5211  		Overloads: []overload{
  5212  			{
  5213  				overloadId: 0,
  5214  				volatile:   true,
  5215  				args:       []types.T{types.T_varchar},
  5216  				retType: func(parameters []types.Type) types.Type {
  5217  					return types.T_int64.ToType()
  5218  				},
  5219  				newOp: func() executeLogicOfOverload {
  5220  					return builtInInternalNumericPrecision
  5221  				},
  5222  			},
  5223  		},
  5224  	},
  5225  
  5226  	// function `internal_numeric_scale`
  5227  	{
  5228  		functionId: INTERNAL_NUMERIC_SCALE,
  5229  		class:      plan.Function_STRICT,
  5230  		layout:     STANDARD_FUNCTION,
  5231  		checkFn:    fixedTypeMatch,
  5232  
  5233  		Overloads: []overload{
  5234  			{
  5235  				overloadId: 0,
  5236  				volatile:   true,
  5237  				args:       []types.T{types.T_varchar},
  5238  				retType: func(parameters []types.Type) types.Type {
  5239  					return types.T_int64.ToType()
  5240  				},
  5241  				newOp: func() executeLogicOfOverload {
  5242  					return builtInInternalNumericScale
  5243  				},
  5244  			},
  5245  		},
  5246  	},
  5247  
  5248  	// function `last_insert_id`
  5249  	{
  5250  		functionId: LAST_INSERT_ID,
  5251  		class:      plan.Function_STRICT,
  5252  		layout:     STANDARD_FUNCTION,
  5253  		checkFn:    fixedTypeMatch,
  5254  
  5255  		Overloads: []overload{
  5256  			{
  5257  				overloadId: 0,
  5258  				args:       []types.T{},
  5259  				volatile:   true,
  5260  				retType: func(parameters []types.Type) types.Type {
  5261  					return types.T_uint64.ToType()
  5262  				},
  5263  				realTimeRelated: true,
  5264  				newOp: func() executeLogicOfOverload {
  5265  					return LastInsertID
  5266  				},
  5267  			},
  5268  		},
  5269  	},
  5270  
  5271  	// function `last_query_id`, `last_uuid`
  5272  	{
  5273  		functionId: LAST_QUERY_ID,
  5274  		class:      plan.Function_STRICT,
  5275  		layout:     STANDARD_FUNCTION,
  5276  		checkFn:    fixedTypeMatch,
  5277  
  5278  		Overloads: []overload{
  5279  			{
  5280  				overloadId:      0,
  5281  				args:            []types.T{},
  5282  				volatile:        true,
  5283  				realTimeRelated: true,
  5284  				retType: func(parameters []types.Type) types.Type {
  5285  					return types.T_varchar.ToType()
  5286  				},
  5287  				newOp: func() executeLogicOfOverload {
  5288  					return LastQueryIDWithoutParam
  5289  				},
  5290  			},
  5291  			{
  5292  				overloadId:      1,
  5293  				args:            []types.T{types.T_int64},
  5294  				volatile:        true,
  5295  				realTimeRelated: true,
  5296  				retType: func(parameters []types.Type) types.Type {
  5297  					return types.T_varchar.ToType()
  5298  				},
  5299  				newOp: func() executeLogicOfOverload {
  5300  					return LastQueryID
  5301  				},
  5302  			},
  5303  		},
  5304  	},
  5305  
  5306  	// function `load_file`
  5307  	// confused function.
  5308  	{
  5309  		functionId: LOAD_FILE,
  5310  		class:      plan.Function_STRICT,
  5311  		layout:     STANDARD_FUNCTION,
  5312  		checkFn:    fixedTypeMatch,
  5313  
  5314  		Overloads: []overload{
  5315  			{
  5316  				overloadId: 0,
  5317  				volatile:   true,
  5318  				args:       []types.T{types.T_varchar},
  5319  				retType: func(parameters []types.Type) types.Type {
  5320  					return types.T_text.ToType()
  5321  				},
  5322  				newOp: func() executeLogicOfOverload {
  5323  					return LoadFile
  5324  				},
  5325  			},
  5326  			{
  5327  				overloadId: 0,
  5328  				volatile:   true,
  5329  				args:       []types.T{types.T_char},
  5330  				retType: func(parameters []types.Type) types.Type {
  5331  					return types.T_text.ToType()
  5332  				},
  5333  				newOp: func() executeLogicOfOverload {
  5334  					return LoadFile
  5335  				},
  5336  			},
  5337  		},
  5338  	},
  5339  
  5340  	// function `mo_memory_usage`
  5341  	{
  5342  		functionId: MO_MEMORY_USAGE,
  5343  		class:      plan.Function_INTERNAL,
  5344  		layout:     STANDARD_FUNCTION,
  5345  		checkFn:    fixedTypeMatch,
  5346  
  5347  		Overloads: []overload{
  5348  			{
  5349  				overloadId:      0,
  5350  				volatile:        true,
  5351  				realTimeRelated: true,
  5352  				args:            []types.T{types.T_varchar},
  5353  				retType: func(parameters []types.Type) types.Type {
  5354  					return types.T_varchar.ToType()
  5355  				},
  5356  				newOp: func() executeLogicOfOverload {
  5357  					return MoMemUsage
  5358  				},
  5359  			},
  5360  		},
  5361  	},
  5362  	// function `mo_memory`
  5363  	{
  5364  		functionId: MO_MEMORY,
  5365  		class:      plan.Function_INTERNAL,
  5366  		layout:     STANDARD_FUNCTION,
  5367  		checkFn:    fixedTypeMatch,
  5368  		Overloads: []overload{
  5369  			{
  5370  				overloadId:      0,
  5371  				volatile:        true,
  5372  				realTimeRelated: true,
  5373  				args:            []types.T{types.T_varchar},
  5374  				retType: func(parameters []types.Type) types.Type {
  5375  					return types.T_int64.ToType()
  5376  				},
  5377  				newOp: func() executeLogicOfOverload {
  5378  					return MoMemory
  5379  				},
  5380  			},
  5381  		},
  5382  	},
  5383  	// function `mo_cpu`
  5384  	{
  5385  		functionId: MO_CPU,
  5386  		class:      plan.Function_INTERNAL,
  5387  		layout:     STANDARD_FUNCTION,
  5388  		checkFn:    fixedTypeMatch,
  5389  		Overloads: []overload{
  5390  			{
  5391  				overloadId:      0,
  5392  				volatile:        true,
  5393  				realTimeRelated: true,
  5394  				args:            []types.T{types.T_varchar},
  5395  				retType: func(parameters []types.Type) types.Type {
  5396  					return types.T_int64.ToType()
  5397  				},
  5398  				newOp: func() executeLogicOfOverload {
  5399  					return MoCPU
  5400  				},
  5401  			},
  5402  		},
  5403  	},
  5404  	// function `mo_cpu_dump`
  5405  	{
  5406  		functionId: MO_CPU_DUMP,
  5407  		class:      plan.Function_INTERNAL,
  5408  		layout:     STANDARD_FUNCTION,
  5409  		checkFn:    fixedTypeMatch,
  5410  		Overloads: []overload{
  5411  			{
  5412  				overloadId:      0,
  5413  				volatile:        true,
  5414  				realTimeRelated: true,
  5415  				args:            []types.T{types.T_varchar},
  5416  				retType: func(parameters []types.Type) types.Type {
  5417  					return types.T_varchar.ToType()
  5418  				},
  5419  				newOp: func() executeLogicOfOverload {
  5420  					return MoCPUDump
  5421  				},
  5422  			},
  5423  		},
  5424  	},
  5425  
  5426  	// function `mo_show_visible_bin`
  5427  	{
  5428  		functionId: MO_SHOW_VISIBLE_BIN,
  5429  		class:      plan.Function_STRICT,
  5430  		layout:     STANDARD_FUNCTION,
  5431  		checkFn:    fixedTypeMatch,
  5432  
  5433  		Overloads: []overload{
  5434  			{
  5435  				overloadId: 0,
  5436  				volatile:   true,
  5437  				args:       []types.T{types.T_varchar, types.T_uint8},
  5438  				retType: func(parameters []types.Type) types.Type {
  5439  					return types.T_varchar.ToType()
  5440  				},
  5441  				newOp: func() executeLogicOfOverload {
  5442  					return builtInMoShowVisibleBin
  5443  				},
  5444  			},
  5445  		},
  5446  	},
  5447  
  5448  	// function `mo_show_visible_bin_enum`
  5449  	{
  5450  		functionId: MO_SHOW_VISIBLE_BIN_ENUM,
  5451  		class:      plan.Function_STRICT,
  5452  		layout:     STANDARD_FUNCTION,
  5453  		checkFn:    fixedTypeMatch,
  5454  
  5455  		Overloads: []overload{
  5456  			{
  5457  				overloadId: 0,
  5458  				volatile:   true,
  5459  				args:       []types.T{types.T_varchar, types.T_varchar},
  5460  				retType: func(parameters []types.Type) types.Type {
  5461  					return types.T_varchar.ToType()
  5462  				},
  5463  				newOp: func() executeLogicOfOverload {
  5464  					return builtInMoShowVisibleBinEnum
  5465  				},
  5466  			},
  5467  		},
  5468  	},
  5469  
  5470  	// function `cast_index_to_value`
  5471  	{
  5472  		functionId: CAST_INDEX_TO_VALUE,
  5473  		class:      plan.Function_STRICT,
  5474  		layout:     STANDARD_FUNCTION,
  5475  		checkFn:    fixedTypeMatch,
  5476  
  5477  		Overloads: []overload{
  5478  			{
  5479  				overloadId:      0,
  5480  				args:            []types.T{types.T_varchar, types.T_uint16},
  5481  				volatile:        true,
  5482  				realTimeRelated: true,
  5483  				retType: func(parameters []types.Type) types.Type {
  5484  					return types.T_varchar.ToType()
  5485  				},
  5486  				newOp: func() executeLogicOfOverload {
  5487  					return CastIndexToValue
  5488  				},
  5489  			},
  5490  		},
  5491  	},
  5492  
  5493  	// function `cast_value_to_index`
  5494  	{
  5495  		functionId: CAST_VALUE_TO_INDEX,
  5496  		class:      plan.Function_STRICT,
  5497  		layout:     STANDARD_FUNCTION,
  5498  		checkFn:    fixedTypeMatch,
  5499  
  5500  		Overloads: []overload{
  5501  			{
  5502  				overloadId:      0,
  5503  				args:            []types.T{types.T_varchar, types.T_varchar},
  5504  				volatile:        true,
  5505  				realTimeRelated: true,
  5506  				retType: func(parameters []types.Type) types.Type {
  5507  					return types.T_uint16.ToType()
  5508  				},
  5509  				newOp: func() executeLogicOfOverload {
  5510  					return CastValueToIndex
  5511  				},
  5512  			},
  5513  		},
  5514  	},
  5515  
  5516  	// function `cast_index_value_to_index`
  5517  	{
  5518  		functionId: CAST_INDEX_VALUE_TO_INDEX,
  5519  		class:      plan.Function_STRICT,
  5520  		layout:     STANDARD_FUNCTION,
  5521  		checkFn:    fixedTypeMatch,
  5522  
  5523  		Overloads: []overload{
  5524  			{
  5525  				overloadId:      0,
  5526  				args:            []types.T{types.T_varchar, types.T_uint16},
  5527  				volatile:        true,
  5528  				realTimeRelated: true,
  5529  				retType: func(parameters []types.Type) types.Type {
  5530  					return types.T_uint16.ToType()
  5531  				},
  5532  				newOp: func() executeLogicOfOverload {
  5533  					return CastIndexValueToIndex
  5534  				},
  5535  			},
  5536  		},
  5537  	},
  5538  
  5539  	// function `cast_nano_to_timestamp`
  5540  	{
  5541  		functionId: CAST_NANO_TO_TIMESTAMP,
  5542  		class:      plan.Function_STRICT,
  5543  		layout:     STANDARD_FUNCTION,
  5544  		checkFn:    fixedTypeMatch,
  5545  
  5546  		Overloads: []overload{
  5547  			{
  5548  				overloadId:      0,
  5549  				args:            []types.T{types.T_int64},
  5550  				volatile:        true,
  5551  				realTimeRelated: true,
  5552  				retType: func(parameters []types.Type) types.Type {
  5553  					return types.T_varchar.ToType()
  5554  				},
  5555  				newOp: func() executeLogicOfOverload {
  5556  					return CastNanoToTimestamp
  5557  				},
  5558  			},
  5559  		},
  5560  	},
  5561  
  5562  	// function `mo_table_rows`
  5563  	{
  5564  		functionId: MO_TABLE_ROWS,
  5565  		class:      plan.Function_STRICT,
  5566  		layout:     STANDARD_FUNCTION,
  5567  		checkFn:    fixedTypeMatch,
  5568  
  5569  		Overloads: []overload{
  5570  			{
  5571  				overloadId:      0,
  5572  				args:            []types.T{types.T_varchar, types.T_varchar},
  5573  				volatile:        true,
  5574  				realTimeRelated: true,
  5575  				retType: func(parameters []types.Type) types.Type {
  5576  					return types.T_int64.ToType()
  5577  				},
  5578  				newOp: func() executeLogicOfOverload {
  5579  					return MoTableRows
  5580  				},
  5581  			},
  5582  		},
  5583  	},
  5584  
  5585  	// function `mo_table_size`
  5586  	{
  5587  		functionId: MO_TABLE_SIZE,
  5588  		class:      plan.Function_STRICT,
  5589  		layout:     STANDARD_FUNCTION,
  5590  		checkFn:    fixedTypeMatch,
  5591  
  5592  		Overloads: []overload{
  5593  			{
  5594  				overloadId:      0,
  5595  				args:            []types.T{types.T_varchar, types.T_varchar},
  5596  				volatile:        true,
  5597  				realTimeRelated: true,
  5598  				retType: func(parameters []types.Type) types.Type {
  5599  					return types.T_int64.ToType()
  5600  				},
  5601  				newOp: func() executeLogicOfOverload {
  5602  					return MoTableSize
  5603  				},
  5604  			},
  5605  		},
  5606  	},
  5607  
  5608  	// function `mo_table_col_max`
  5609  	{
  5610  		functionId: MO_TABLE_COL_MAX,
  5611  		class:      plan.Function_STRICT,
  5612  		layout:     STANDARD_FUNCTION,
  5613  		checkFn:    fixedTypeMatch,
  5614  
  5615  		Overloads: []overload{
  5616  			{
  5617  				overloadId:      0,
  5618  				args:            []types.T{types.T_varchar, types.T_varchar, types.T_varchar},
  5619  				volatile:        true,
  5620  				realTimeRelated: true,
  5621  				retType: func(parameters []types.Type) types.Type {
  5622  					return types.T_varchar.ToType()
  5623  				},
  5624  				newOp: func() executeLogicOfOverload {
  5625  					return MoTableColMax
  5626  				},
  5627  			},
  5628  		},
  5629  	},
  5630  
  5631  	// function `mo_table_col_min`
  5632  	{
  5633  		functionId: MO_TABLE_COL_MIN,
  5634  		class:      plan.Function_STRICT,
  5635  		layout:     STANDARD_FUNCTION,
  5636  		checkFn:    fixedTypeMatch,
  5637  
  5638  		Overloads: []overload{
  5639  			{
  5640  				overloadId:      0,
  5641  				args:            []types.T{types.T_varchar, types.T_varchar, types.T_varchar},
  5642  				volatile:        true,
  5643  				realTimeRelated: true,
  5644  				retType: func(parameters []types.Type) types.Type {
  5645  					return types.T_varchar.ToType()
  5646  				},
  5647  				newOp: func() executeLogicOfOverload {
  5648  					return MoTableColMin
  5649  				},
  5650  			},
  5651  		},
  5652  	},
  5653  
  5654  	// function `roles_graphml`
  5655  	{
  5656  		functionId: ROLES_GRAPHML,
  5657  		class:      plan.Function_STRICT,
  5658  		layout:     STANDARD_FUNCTION,
  5659  		checkFn:    fixedTypeMatch,
  5660  
  5661  		Overloads: []overload{
  5662  			{
  5663  				overloadId: 0,
  5664  				args:       []types.T{},
  5665  				retType: func(parameters []types.Type) types.Type {
  5666  					return types.T_varchar.ToType()
  5667  				},
  5668  				newOp: func() executeLogicOfOverload {
  5669  					return RolesGraphml
  5670  				},
  5671  			},
  5672  		},
  5673  	},
  5674  
  5675  	// function `row_count`
  5676  	{
  5677  		functionId: ROW_COUNT,
  5678  		class:      plan.Function_STRICT,
  5679  		layout:     STANDARD_FUNCTION,
  5680  		checkFn:    fixedTypeMatch,
  5681  
  5682  		Overloads: []overload{
  5683  			{
  5684  				overloadId: 0,
  5685  				args:       []types.T{},
  5686  				retType: func(parameters []types.Type) types.Type {
  5687  					return types.T_uint64.ToType()
  5688  				},
  5689  				newOp: func() executeLogicOfOverload {
  5690  					return RowCount
  5691  				},
  5692  			},
  5693  		},
  5694  	},
  5695  
  5696  	// sequence related functions
  5697  	// function `nextval`
  5698  	{
  5699  		functionId: NEXTVAL,
  5700  		class:      plan.Function_STRICT,
  5701  		layout:     UNKNOW_KIND_FUNCTION,
  5702  		checkFn:    fixedTypeMatch,
  5703  
  5704  		Overloads: []overload{
  5705  			{
  5706  				overloadId:      0,
  5707  				args:            []types.T{types.T_varchar},
  5708  				volatile:        true,
  5709  				realTimeRelated: true,
  5710  				retType: func(parameters []types.Type) types.Type {
  5711  					return types.T_varchar.ToType()
  5712  				},
  5713  				newOp: func() executeLogicOfOverload {
  5714  					return Nextval
  5715  				},
  5716  			},
  5717  		},
  5718  	},
  5719  	// function `setval`
  5720  	{
  5721  		functionId: SETVAL,
  5722  		class:      plan.Function_STRICT,
  5723  		layout:     UNKNOW_KIND_FUNCTION,
  5724  		checkFn:    fixedTypeMatch,
  5725  
  5726  		Overloads: []overload{
  5727  			{
  5728  				overloadId: 0,
  5729  				args: []types.T{
  5730  					types.T_varchar,
  5731  					types.T_varchar,
  5732  				},
  5733  				volatile:        true,
  5734  				realTimeRelated: true,
  5735  				retType: func(parameters []types.Type) types.Type {
  5736  					return types.T_varchar.ToType()
  5737  				},
  5738  				newOp: func() executeLogicOfOverload {
  5739  					return Setval
  5740  				},
  5741  			},
  5742  			{
  5743  				overloadId: 1,
  5744  				args: []types.T{
  5745  					types.T_varchar,
  5746  					types.T_varchar,
  5747  					types.T_bool,
  5748  				},
  5749  				volatile:        true,
  5750  				realTimeRelated: true,
  5751  				retType: func(parameters []types.Type) types.Type {
  5752  					return types.T_varchar.ToType()
  5753  				},
  5754  				newOp: func() executeLogicOfOverload {
  5755  					return Setval
  5756  				},
  5757  			},
  5758  		},
  5759  	},
  5760  	// function `currval`
  5761  	{
  5762  		functionId: CURRVAL,
  5763  		class:      plan.Function_STRICT,
  5764  		layout:     UNKNOW_KIND_FUNCTION,
  5765  		checkFn:    fixedTypeMatch,
  5766  
  5767  		Overloads: []overload{
  5768  			{
  5769  				overloadId:      0,
  5770  				args:            []types.T{types.T_varchar},
  5771  				volatile:        true,
  5772  				realTimeRelated: true,
  5773  				retType: func(parameters []types.Type) types.Type {
  5774  					return types.T_varchar.ToType()
  5775  				},
  5776  				newOp: func() executeLogicOfOverload {
  5777  					return Currval
  5778  				},
  5779  			},
  5780  		},
  5781  	},
  5782  	// function lastval
  5783  	{
  5784  		functionId: LASTVAL,
  5785  		class:      plan.Function_STRICT,
  5786  		layout:     UNKNOW_KIND_FUNCTION,
  5787  		checkFn:    fixedTypeMatch,
  5788  
  5789  		Overloads: []overload{
  5790  			{
  5791  				overloadId:      0,
  5792  				args:            nil,
  5793  				volatile:        true,
  5794  				realTimeRelated: true,
  5795  				retType: func(parameters []types.Type) types.Type {
  5796  					return types.T_varchar.ToType()
  5797  				},
  5798  				newOp: func() executeLogicOfOverload {
  5799  					return Lastval
  5800  				},
  5801  			},
  5802  		},
  5803  	},
  5804  
  5805  	// function `user`, `system_user`, "current_user", "session_user"
  5806  	{
  5807  		functionId: USER,
  5808  		class:      plan.Function_STRICT,
  5809  		layout:     STANDARD_FUNCTION,
  5810  		checkFn:    fixedTypeMatch,
  5811  
  5812  		Overloads: []overload{
  5813  			{
  5814  				overloadId: 0,
  5815  				args:       []types.T{},
  5816  				volatile:   true,
  5817  				retType: func(parameters []types.Type) types.Type {
  5818  					return types.T_varchar.ToType()
  5819  				},
  5820  				newOp: func() executeLogicOfOverload {
  5821  					return User
  5822  				},
  5823  			},
  5824  		},
  5825  	},
  5826  
  5827  	// function `uuid`
  5828  	{
  5829  		functionId: UUID,
  5830  		class:      plan.Function_STRICT,
  5831  		layout:     STANDARD_FUNCTION,
  5832  		checkFn:    fixedTypeMatch,
  5833  
  5834  		Overloads: []overload{
  5835  			{
  5836  				overloadId: 0,
  5837  				volatile:   true,
  5838  				retType: func(parameters []types.Type) types.Type {
  5839  					return types.T_uuid.ToType()
  5840  				},
  5841  				newOp: func() executeLogicOfOverload {
  5842  					return builtInUUID
  5843  				},
  5844  			},
  5845  		},
  5846  	},
  5847  
  5848  	// function `values`
  5849  	{
  5850  		functionId: VALUES,
  5851  		class:      plan.Function_STRICT,
  5852  		layout:     STANDARD_FUNCTION,
  5853  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
  5854  			if len(inputs) == 1 {
  5855  				return newCheckResultWithSuccess(0)
  5856  			}
  5857  			return newCheckResultWithFailure(failedFunctionParametersWrong)
  5858  		},
  5859  
  5860  		Overloads: []overload{
  5861  			{
  5862  				overloadId: 0,
  5863  				retType: func(parameters []types.Type) types.Type {
  5864  					return parameters[0]
  5865  				},
  5866  				newOp: func() executeLogicOfOverload {
  5867  					return Values
  5868  				},
  5869  			},
  5870  		},
  5871  	},
  5872  
  5873  	// function `version`
  5874  	{
  5875  		functionId: VERSION,
  5876  		class:      plan.Function_STRICT,
  5877  		layout:     STANDARD_FUNCTION,
  5878  		checkFn:    fixedTypeMatch,
  5879  
  5880  		Overloads: []overload{
  5881  			{
  5882  				overloadId:      0,
  5883  				args:            nil,
  5884  				realTimeRelated: true,
  5885  				retType: func(parameters []types.Type) types.Type {
  5886  					return types.T_varchar.ToType()
  5887  				},
  5888  				newOp: func() executeLogicOfOverload {
  5889  					return Version
  5890  				},
  5891  			},
  5892  		},
  5893  	},
  5894  
  5895  	// function `mo_check_level`
  5896  	{
  5897  		functionId: MO_CHECH_LEVEL,
  5898  		class:      plan.Function_STRICT,
  5899  		layout:     STANDARD_FUNCTION,
  5900  		checkFn:    fixedTypeMatch,
  5901  
  5902  		Overloads: []overload{
  5903  			{
  5904  				overloadId: 0,
  5905  				args:       []types.T{types.T_bool},
  5906  				retType: func(parameters []types.Type) types.Type {
  5907  					return types.T_bool.ToType()
  5908  				},
  5909  				newOp: func() executeLogicOfOverload {
  5910  					return func(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  5911  						vs := vector.GenerateFunctionFixedTypeParameter[bool](parameters[0])
  5912  						res := vector.MustFunctionResult[bool](result)
  5913  						for i := uint64(0); i < uint64(length); i++ {
  5914  							flag, isNull := vs.GetValue(i)
  5915  							if isNull || !flag {
  5916  								return moerr.NewCheckRecursiveLevel(proc.Ctx)
  5917  							}
  5918  							res.AppendMustValue(true)
  5919  						}
  5920  						return nil
  5921  					}
  5922  				},
  5923  			},
  5924  		},
  5925  	},
  5926  
  5927  	// function `assert`
  5928  	{
  5929  		functionId: ASSERT,
  5930  		class:      plan.Function_STRICT,
  5931  		layout:     STANDARD_FUNCTION,
  5932  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
  5933  			if len(inputs) == 4 {
  5934  				if inputs[0].Oid != types.T_bool || !inputs[1].Oid.IsMySQLString() || !inputs[2].Oid.IsMySQLString() || !inputs[3].Oid.IsMySQLString() {
  5935  					return newCheckResultWithFailure(failedFunctionParametersWrong)
  5936  				}
  5937  				return newCheckResultWithSuccess(1)
  5938  			}
  5939  
  5940  			if len(inputs) == 2 {
  5941  				if inputs[0].Oid != types.T_bool || !inputs[1].Oid.IsMySQLString() {
  5942  					return newCheckResultWithFailure(failedFunctionParametersWrong)
  5943  				}
  5944  				return newCheckResultWithSuccess(0)
  5945  			}
  5946  			return newCheckResultWithFailure(failedFunctionParametersWrong)
  5947  		},
  5948  
  5949  		Overloads: []overload{
  5950  			{
  5951  				overloadId: 0,
  5952  				retType: func(parameters []types.Type) types.Type {
  5953  					return types.T_bool.ToType()
  5954  				},
  5955  				newOp: func() executeLogicOfOverload {
  5956  					return func(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  5957  						checkFlags := vector.GenerateFunctionFixedTypeParameter[bool](parameters[0])
  5958  						errMsgs := vector.GenerateFunctionStrParameter(parameters[1])
  5959  						value2, null := errMsgs.GetStrValue(0)
  5960  						if null {
  5961  							return moerr.NewInternalError(proc.Ctx, "the second parameter of assert() should not be null")
  5962  						}
  5963  						errMsg := functionUtil.QuickBytesToStr(value2)
  5964  
  5965  						res := vector.MustFunctionResult[bool](result)
  5966  						for i := uint64(0); i < uint64(length); i++ {
  5967  							flag, isNull := checkFlags.GetValue(i)
  5968  							if isNull || !flag {
  5969  								return moerr.NewInternalError(proc.Ctx, errMsg)
  5970  							}
  5971  							res.AppendMustValue(true)
  5972  						}
  5973  						return nil
  5974  					}
  5975  				},
  5976  			},
  5977  			{
  5978  				overloadId: 1,
  5979  				retType: func(parameters []types.Type) types.Type {
  5980  					return types.T_bool.ToType()
  5981  				},
  5982  				newOp: func() executeLogicOfOverload {
  5983  					return func(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  5984  						checkFlags := vector.GenerateFunctionFixedTypeParameter[bool](parameters[0])
  5985  						sourceValues := vector.GenerateFunctionStrParameter(parameters[1])
  5986  						columnNames := vector.GenerateFunctionStrParameter(parameters[2])
  5987  						columnTypes := vector.GenerateFunctionStrParameter(parameters[3])
  5988  						// do a safe check
  5989  						if columnNames.WithAnyNullValue() {
  5990  							return moerr.NewInternalError(proc.Ctx, "the third parameter of assert() should not be null")
  5991  						}
  5992  						res := vector.MustFunctionResult[bool](result)
  5993  						loopLength := uint64(length)
  5994  
  5995  						// bad design.
  5996  						castFlag := parameters[1].GetType().Width == types.MaxVarcharLen
  5997  						if castFlag {
  5998  							for i := uint64(0); i < loopLength; i++ {
  5999  								flag, null1 := checkFlags.GetValue(i)
  6000  								if null1 || !flag {
  6001  									value, null2 := sourceValues.GetStrValue(i)
  6002  									col, _ := columnNames.GetStrValue(i)
  6003  									coltypes, _ := columnTypes.GetStrValue(i)
  6004  									if !null2 {
  6005  										tuples, _, schema, err := types.DecodeTuple(value)
  6006  										scales := make([]int32, max(len(coltypes), len(schema)))
  6007  										for j := range coltypes {
  6008  											scales[j] = int32(coltypes[j])
  6009  										}
  6010  										if err == nil { // complex key
  6011  											return moerr.NewDuplicateEntry(proc.Ctx, tuples.ErrString(scales), string(col))
  6012  										}
  6013  										return moerr.NewDuplicateEntry(proc.Ctx, string(value), string(col))
  6014  									}
  6015  									return moerr.NewInternalError(proc.Ctx, fmt.Sprintf("column '%s' cannot be null", string(col)))
  6016  								}
  6017  								res.AppendMustValue(true)
  6018  							}
  6019  						} else {
  6020  							for i := uint64(0); i < loopLength; i++ {
  6021  								flag, null1 := checkFlags.GetValue(i)
  6022  								if null1 || !flag {
  6023  									value, null2 := sourceValues.GetStrValue(i)
  6024  									col, _ := columnNames.GetStrValue(i)
  6025  									if !null2 {
  6026  										return moerr.NewDuplicateEntry(proc.Ctx, string(value), string(col))
  6027  									}
  6028  									return moerr.NewInternalError(proc.Ctx, fmt.Sprintf("column '%s' cannot be null", string(col)))
  6029  								}
  6030  								res.AppendMustValue(true)
  6031  							}
  6032  						}
  6033  						return nil
  6034  					}
  6035  				},
  6036  			},
  6037  		},
  6038  	},
  6039  
  6040  	// function `isempty`
  6041  	{
  6042  		functionId: ISEMPTY,
  6043  		class:      plan.Function_STRICT,
  6044  		layout:     STANDARD_FUNCTION,
  6045  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
  6046  			if len(inputs) != 1 {
  6047  				return newCheckResultWithFailure(failedFunctionParametersWrong)
  6048  			}
  6049  			return newCheckResultWithSuccess(0)
  6050  		},
  6051  
  6052  		Overloads: []overload{
  6053  			{
  6054  				overloadId: 0,
  6055  				retType: func(parameters []types.Type) types.Type {
  6056  					return types.T_bool.ToType()
  6057  				},
  6058  				newOp: func() executeLogicOfOverload {
  6059  					return func(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  6060  						isEmpty := parameters[0].Length() == 0
  6061  						res := vector.MustFunctionResult[bool](result)
  6062  						for i := uint64(0); i < uint64(length); i++ {
  6063  							res.AppendMustValue(isEmpty)
  6064  						}
  6065  						return nil
  6066  					}
  6067  				},
  6068  			},
  6069  		},
  6070  	},
  6071  
  6072  	// function `not_in_rows`
  6073  	{
  6074  		functionId: NOT_IN_ROWS,
  6075  		class:      plan.Function_STRICT,
  6076  		layout:     STANDARD_FUNCTION,
  6077  		checkFn: func(overloads []overload, inputs []types.Type) checkResult {
  6078  			if len(inputs) != 2 {
  6079  				return newCheckResultWithFailure(failedFunctionParametersWrong)
  6080  			}
  6081  			if inputs[0].Oid != types.T_Rowid || inputs[1].Oid != types.T_Rowid {
  6082  				return newCheckResultWithFailure(failedFunctionParametersWrong)
  6083  			}
  6084  			return newCheckResultWithSuccess(0)
  6085  		},
  6086  
  6087  		Overloads: []overload{
  6088  			{
  6089  				overloadId: 0,
  6090  				retType: func(parameters []types.Type) types.Type {
  6091  					return types.T_bool.ToType()
  6092  				},
  6093  				newOp: func() executeLogicOfOverload {
  6094  					return func(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  6095  						leftRow := vector.GenerateFunctionFixedTypeParameter[types.Rowid](parameters[0])
  6096  						rightRow := vector.GenerateFunctionFixedTypeParameter[types.Rowid](parameters[1])
  6097  						res := vector.MustFunctionResult[bool](result)
  6098  
  6099  						var rightRowIdMap map[types.Rowid]struct{}
  6100  						if rightRow.WithAnyNullValue() {
  6101  							rightRowIdMap = make(map[types.Rowid]struct{})
  6102  						} else {
  6103  							// XXX not sure, but row_id may not be duplicated I think.
  6104  							rightRowIdMap = make(map[types.Rowid]struct{}, length)
  6105  						}
  6106  
  6107  						loopLength := uint64(length)
  6108  						for i := uint64(0); i < loopLength; i++ {
  6109  							rightRowId, isNull := rightRow.GetValue(i)
  6110  							if !isNull {
  6111  								rightRowIdMap[rightRowId] = struct{}{}
  6112  							}
  6113  						}
  6114  
  6115  						for i := uint64(0); i < loopLength; i++ {
  6116  							leftRowId, isNull := leftRow.GetValue(i)
  6117  							notInRows := false
  6118  							if !isNull {
  6119  								if _, ok := rightRowIdMap[leftRowId]; !ok {
  6120  									notInRows = true
  6121  								}
  6122  							}
  6123  							res.AppendMustValue(notInRows)
  6124  						}
  6125  						return nil
  6126  					}
  6127  				},
  6128  			},
  6129  		},
  6130  	},
  6131  
  6132  	// function `python_user_defined_function`
  6133  	{
  6134  		functionId: PYTHON_UDF,
  6135  		class:      plan.Function_INTERNAL | plan.Function_STRICT,
  6136  		layout:     STANDARD_FUNCTION,
  6137  		checkFn:    checkPythonUdf,
  6138  		Overloads: []overload{
  6139  			{
  6140  				overloadId: 0,
  6141  				retType:    pythonUdfRetType,
  6142  				newOp: func() executeLogicOfOverload {
  6143  					return runPythonUdf
  6144  				},
  6145  			},
  6146  		},
  6147  	},
  6148  
  6149  	// function `BITMAP_BIT_POSITION`
  6150  	{
  6151  		functionId: BITMAP_BIT_POSITION,
  6152  		class:      plan.Function_STRICT,
  6153  		layout:     STANDARD_FUNCTION,
  6154  		checkFn:    fixedTypeMatch,
  6155  
  6156  		Overloads: []overload{
  6157  			{
  6158  				overloadId: 0,
  6159  				args:       []types.T{types.T_uint64},
  6160  				retType: func(parameters []types.Type) types.Type {
  6161  					return types.T_uint64.ToType()
  6162  				},
  6163  				newOp: func() executeLogicOfOverload {
  6164  					return BitmapBitPosition
  6165  				},
  6166  			},
  6167  		},
  6168  	},
  6169  
  6170  	// function `BITMAP_BUCKET_NUMBER`
  6171  	{
  6172  		functionId: BITMAP_BUCKET_NUMBER,
  6173  		class:      plan.Function_STRICT,
  6174  		layout:     STANDARD_FUNCTION,
  6175  		checkFn:    fixedTypeMatch,
  6176  
  6177  		Overloads: []overload{
  6178  			{
  6179  				overloadId: 0,
  6180  				args:       []types.T{types.T_uint64},
  6181  				retType: func(parameters []types.Type) types.Type {
  6182  					return types.T_uint64.ToType()
  6183  				},
  6184  				newOp: func() executeLogicOfOverload {
  6185  					return BitmapBucketNumber
  6186  				},
  6187  			},
  6188  		},
  6189  	},
  6190  
  6191  	// function `BITMAP_COUNT`
  6192  	{
  6193  		functionId: BITMAP_COUNT,
  6194  		class:      plan.Function_STRICT,
  6195  		layout:     STANDARD_FUNCTION,
  6196  		checkFn:    fixedTypeMatch,
  6197  
  6198  		Overloads: []overload{
  6199  			{
  6200  				overloadId: 0,
  6201  				args:       []types.T{types.T_varbinary},
  6202  				retType: func(parameters []types.Type) types.Type {
  6203  					return types.T_uint64.ToType()
  6204  				},
  6205  				newOp: func() executeLogicOfOverload {
  6206  					return BitmapCount
  6207  				},
  6208  			},
  6209  		},
  6210  	},
  6211  
  6212  	// function `SHA1`
  6213  	{
  6214  		functionId: SHA1,
  6215  		class:      plan.Function_STRICT,
  6216  		layout:     STANDARD_FUNCTION,
  6217  		checkFn:    fixedTypeMatch,
  6218  
  6219  		Overloads: []overload{
  6220  			{
  6221  				overloadId: 0,
  6222  				args:       []types.T{types.T_varchar},
  6223  				retType: func(parameters []types.Type) types.Type {
  6224  					return types.T_varchar.ToType()
  6225  				},
  6226  				newOp: func() executeLogicOfOverload {
  6227  					return SHA1Func
  6228  				},
  6229  			},
  6230  		},
  6231  	},
  6232  }