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

     1  // Copyright 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  	"testing"
    20  	"time"
    21  
    22  	"github.com/matrixorigin/matrixone/pkg/container/types"
    23  	"github.com/matrixorigin/matrixone/pkg/testutil"
    24  	"github.com/stretchr/testify/require"
    25  )
    26  
    27  func initCastTestCase() []tcTemp {
    28  	var testCases []tcTemp
    29  
    30  	// used on case.
    31  	f1251ToDec128, _ := types.Decimal128FromFloat64(125.1, 38, 1)
    32  	s01date, _ := types.ParseDateCast("2004-04-03")
    33  	s02date, _ := types.ParseDateCast("2021-10-03")
    34  	s01ts, _ := types.ParseTimestamp(time.Local, "2020-08-23 11:52:21", 6)
    35  
    36  	castToSameTypeCases := []tcTemp{
    37  		// cast to same type.
    38  		{
    39  			info: "int8 to int8",
    40  			inputs: []testutil.FunctionTestInput{
    41  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
    42  					[]int8{-23}, []bool{false}),
    43  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
    44  			},
    45  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
    46  				[]int8{-23}, []bool{false}),
    47  		},
    48  		{
    49  			info: "int16 to int16",
    50  			inputs: []testutil.FunctionTestInput{
    51  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
    52  					[]int16{-23}, []bool{false}),
    53  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
    54  			},
    55  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
    56  				[]int16{-23}, []bool{false}),
    57  		},
    58  		{
    59  			info: "int32 to int32",
    60  			inputs: []testutil.FunctionTestInput{
    61  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
    62  					[]int32{-23}, []bool{false}),
    63  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
    64  			},
    65  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
    66  				[]int32{-23}, []bool{false}),
    67  		},
    68  		{
    69  			info: "int64 to int64",
    70  			inputs: []testutil.FunctionTestInput{
    71  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
    72  					[]int64{-23}, []bool{false}),
    73  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
    74  			},
    75  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
    76  				[]int64{-23}, []bool{false}),
    77  		},
    78  		{
    79  			info: "uint8 to uint8",
    80  			inputs: []testutil.FunctionTestInput{
    81  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
    82  					[]uint8{23}, []bool{false}),
    83  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
    84  			},
    85  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
    86  				[]uint8{23}, []bool{false}),
    87  		},
    88  		{
    89  			info: "uint16 to uint16",
    90  			inputs: []testutil.FunctionTestInput{
    91  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
    92  					[]uint16{23}, []bool{false}),
    93  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
    94  			},
    95  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
    96  				[]uint16{23}, []bool{false}),
    97  		},
    98  		{
    99  			info: "uint32 to uint32",
   100  			inputs: []testutil.FunctionTestInput{
   101  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   102  					[]uint32{23}, []bool{false}),
   103  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
   104  			},
   105  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
   106  				[]uint32{23}, []bool{false}),
   107  		},
   108  		{
   109  			info: "uint64 to uint64",
   110  			inputs: []testutil.FunctionTestInput{
   111  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
   112  					[]uint64{23}, []bool{false}),
   113  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
   114  			},
   115  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
   116  				[]uint64{23}, []bool{false}),
   117  		},
   118  		{
   119  			info: "float32 to float32",
   120  			inputs: []testutil.FunctionTestInput{
   121  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
   122  					[]float32{23.5}, []bool{false}),
   123  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
   124  			},
   125  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
   126  				[]float32{23.5}, []bool{false}),
   127  		},
   128  		{
   129  			info: "float64 to float64",
   130  			inputs: []testutil.FunctionTestInput{
   131  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
   132  					[]float64{23.5}, []bool{false}),
   133  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
   134  			},
   135  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
   136  				[]float64{23.5}, []bool{false}),
   137  		},
   138  		{
   139  			info: "date to date",
   140  			inputs: []testutil.FunctionTestInput{
   141  				testutil.NewFunctionTestInput(types.T_date.ToType(),
   142  					[]types.Date{729848}, []bool{false}),
   143  				testutil.NewFunctionTestInput(types.T_date.ToType(), []types.Date{}, []bool{}),
   144  			},
   145  			expect: testutil.NewFunctionTestResult(types.T_date.ToType(), false,
   146  				[]types.Date{729848}, []bool{false}),
   147  		},
   148  		{
   149  			info: "datetime to datetime",
   150  			inputs: []testutil.FunctionTestInput{
   151  				testutil.NewFunctionTestInput(types.T_datetime.ToType(),
   152  					[]types.Datetime{66122056321728512}, []bool{false}),
   153  				testutil.NewFunctionTestInput(types.T_datetime.ToType(), []types.Datetime{}, []bool{}),
   154  			},
   155  			expect: testutil.NewFunctionTestResult(types.T_datetime.ToType(), false,
   156  				[]types.Datetime{66122056321728512}, []bool{false}),
   157  		},
   158  		{
   159  			info: "timestamp to timestamp",
   160  			inputs: []testutil.FunctionTestInput{
   161  				testutil.NewFunctionTestInput(types.T_timestamp.ToType(),
   162  					[]types.Timestamp{66122026122739712}, []bool{false}),
   163  				testutil.NewFunctionTestInput(types.T_timestamp.ToType(), []types.Timestamp{}, []bool{}),
   164  			},
   165  			expect: testutil.NewFunctionTestResult(types.T_timestamp.ToType(), false,
   166  				[]types.Timestamp{66122026122739712}, []bool{false}),
   167  		},
   168  		{
   169  			info: "time to time",
   170  			inputs: []testutil.FunctionTestInput{
   171  				testutil.NewFunctionTestInput(types.T_time.ToType(),
   172  					[]types.Time{661220261227}, []bool{false}),
   173  				testutil.NewFunctionTestInput(types.T_time.ToType(), []types.Time{}, []bool{}),
   174  			},
   175  			expect: testutil.NewFunctionTestResult(types.T_time.ToType(), false,
   176  				[]types.Time{661220261227}, []bool{false}),
   177  		},
   178  		{
   179  			info: "vecf32 to vecf32",
   180  			inputs: []testutil.FunctionTestInput{
   181  				testutil.NewFunctionTestInput(types.T_array_float32.ToType(), [][]float32{{1, 2, 3}}, []bool{false}),
   182  				testutil.NewFunctionTestInput(types.T_array_float32.ToType(), [][]float32{{}}, []bool{}),
   183  			},
   184  			expect: testutil.NewFunctionTestResult(types.T_array_float32.ToType(), false, [][]float32{{1, 2, 3}}, []bool{false}),
   185  		},
   186  		{
   187  			info: "vecf64 to vecf64",
   188  			inputs: []testutil.FunctionTestInput{
   189  				testutil.NewFunctionTestInput(types.T_array_float64.ToType(), [][]float64{{1, 2, 3}}, []bool{false}),
   190  				testutil.NewFunctionTestInput(types.T_array_float64.ToType(), [][]float64{{}}, []bool{}),
   191  			},
   192  			expect: testutil.NewFunctionTestResult(types.T_array_float64.ToType(), false, [][]float64{{1, 2, 3}}, []bool{false}),
   193  		},
   194  		{
   195  			info: "bit to bit",
   196  			inputs: []testutil.FunctionTestInput{
   197  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{23}, []bool{false}),
   198  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
   199  			},
   200  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false, []uint64{23}, []bool{false}),
   201  		},
   202  	}
   203  	castInt8ToOthers := []tcTemp{
   204  		// test cast int8 to others.
   205  		{
   206  			info: "int8 to int16",
   207  			inputs: []testutil.FunctionTestInput{
   208  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
   209  					[]int8{125, 126, 0}, []bool{false, false, true}),
   210  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
   211  			},
   212  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
   213  				[]int16{125, 126, 0}, []bool{false, false, true}),
   214  		},
   215  		{
   216  			info: "int8 to int32",
   217  			inputs: []testutil.FunctionTestInput{
   218  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
   219  					[]int8{125, 126, 0}, []bool{false, false, true}),
   220  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
   221  			},
   222  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
   223  				[]int32{125, 126, 0}, []bool{false, false, true}),
   224  		},
   225  		{
   226  			info: "int8 to int64",
   227  			inputs: []testutil.FunctionTestInput{
   228  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
   229  					[]int8{125, 126, 0}, []bool{false, false, true}),
   230  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
   231  			},
   232  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
   233  				[]int64{125, 126, 0}, []bool{false, false, true}),
   234  		},
   235  		{
   236  			info: "int8 to uint8",
   237  			inputs: []testutil.FunctionTestInput{
   238  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
   239  					[]int8{125, 126, 0}, []bool{false, false, true}),
   240  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
   241  			},
   242  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
   243  				[]uint8{125, 126, 0}, []bool{false, false, true}),
   244  		},
   245  		{
   246  			info: "int8 to uint16",
   247  			inputs: []testutil.FunctionTestInput{
   248  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
   249  					[]int8{125, 126, 0}, []bool{false, false, true}),
   250  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
   251  			},
   252  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
   253  				[]uint16{125, 126, 0}, []bool{false, false, true}),
   254  		},
   255  		{
   256  			info: "int8 to uint32",
   257  			inputs: []testutil.FunctionTestInput{
   258  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
   259  					[]int8{125, 126, 0}, []bool{false, false, true}),
   260  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
   261  			},
   262  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
   263  				[]uint32{125, 126, 0}, []bool{false, false, true}),
   264  		},
   265  		{
   266  			info: "int8 to uint64",
   267  			inputs: []testutil.FunctionTestInput{
   268  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
   269  					[]int8{125, 126, 0}, []bool{false, false, true}),
   270  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
   271  			},
   272  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
   273  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   274  		},
   275  		{
   276  			info: "int8 to float32",
   277  			inputs: []testutil.FunctionTestInput{
   278  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
   279  					[]int8{125, 126, 0}, []bool{false, false, true}),
   280  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
   281  			},
   282  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
   283  				[]float32{125, 126, 0}, []bool{false, false, true}),
   284  		},
   285  		{
   286  			info: "int8 to float64",
   287  			inputs: []testutil.FunctionTestInput{
   288  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
   289  					[]int8{125, 126, 0}, []bool{false, false, true}),
   290  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
   291  			},
   292  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
   293  				[]float64{125, 126, 0}, []bool{false, false, true}),
   294  		},
   295  		{
   296  			info: "int8 to decimal128",
   297  			inputs: []testutil.FunctionTestInput{
   298  				testutil.NewFunctionTestInput(types.T_int8.ToType(),
   299  					[]int8{125, 0}, []bool{false, true}),
   300  				testutil.NewFunctionTestInput(types.T_decimal128.ToType(), []types.Decimal128{}, []bool{}),
   301  			},
   302  			expect: testutil.NewFunctionTestResult(types.T_decimal128.ToType(), false,
   303  				[]types.Decimal128{{B0_63: 125, B64_127: 0}, {B0_63: 0, B64_127: 0}},
   304  				[]bool{false, true}),
   305  		},
   306  		{
   307  			info: "int8 to bit",
   308  			inputs: []testutil.FunctionTestInput{
   309  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{125, 126, 0}, []bool{false, false, true}),
   310  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
   311  			},
   312  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false,
   313  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   314  		},
   315  	}
   316  	castInt16ToOthers := []tcTemp{
   317  		// test cast int16 to others.
   318  		{
   319  			info: "int16 to int8",
   320  			inputs: []testutil.FunctionTestInput{
   321  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
   322  					[]int16{125, 126, 0}, []bool{false, false, true}),
   323  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
   324  			},
   325  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
   326  				[]int8{125, 126, 0}, []bool{false, false, true}),
   327  		},
   328  		{
   329  			info: "int16 to int32",
   330  			inputs: []testutil.FunctionTestInput{
   331  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
   332  					[]int16{125, 126, 0}, []bool{false, false, true}),
   333  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
   334  			},
   335  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
   336  				[]int32{125, 126, 0}, []bool{false, false, true}),
   337  		},
   338  		{
   339  			info: "int16 to int64",
   340  			inputs: []testutil.FunctionTestInput{
   341  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
   342  					[]int16{125, 126, 0}, []bool{false, false, true}),
   343  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
   344  			},
   345  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
   346  				[]int64{125, 126, 0}, []bool{false, false, true}),
   347  		},
   348  		{
   349  			info: "int16 to uint8",
   350  			inputs: []testutil.FunctionTestInput{
   351  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
   352  					[]int16{125, 126, 0}, []bool{false, false, true}),
   353  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
   354  			},
   355  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
   356  				[]uint8{125, 126, 0}, []bool{false, false, true}),
   357  		},
   358  		{
   359  			info: "int16 to uint16",
   360  			inputs: []testutil.FunctionTestInput{
   361  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
   362  					[]int16{125, 126, 0}, []bool{false, false, true}),
   363  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
   364  			},
   365  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
   366  				[]uint16{125, 126, 0}, []bool{false, false, true}),
   367  		},
   368  		{
   369  			info: "int16 to uint32",
   370  			inputs: []testutil.FunctionTestInput{
   371  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
   372  					[]int16{125, 126, 0}, []bool{false, false, true}),
   373  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
   374  			},
   375  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
   376  				[]uint32{125, 126, 0}, []bool{false, false, true}),
   377  		},
   378  		{
   379  			info: "int16 to uint64",
   380  			inputs: []testutil.FunctionTestInput{
   381  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
   382  					[]int16{125, 126, 0}, []bool{false, false, true}),
   383  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
   384  			},
   385  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
   386  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   387  		},
   388  		{
   389  			info: "int16 to float32",
   390  			inputs: []testutil.FunctionTestInput{
   391  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
   392  					[]int16{125, 126, 0}, []bool{false, false, true}),
   393  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
   394  			},
   395  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
   396  				[]float32{125, 126, 0}, []bool{false, false, true}),
   397  		},
   398  		{
   399  			info: "int16 to float64",
   400  			inputs: []testutil.FunctionTestInput{
   401  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
   402  					[]int16{125, 126, 0}, []bool{false, false, true}),
   403  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
   404  			},
   405  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
   406  				[]float64{125, 126, 0}, []bool{false, false, true}),
   407  		},
   408  		{
   409  			info: "int16 to decimal128",
   410  			inputs: []testutil.FunctionTestInput{
   411  				testutil.NewFunctionTestInput(types.T_int16.ToType(),
   412  					[]int16{125, 0}, []bool{false, true}),
   413  				testutil.NewFunctionTestInput(types.T_decimal128.ToType(), []types.Decimal128{}, []bool{}),
   414  			},
   415  			expect: testutil.NewFunctionTestResult(types.T_decimal128.ToType(), false,
   416  				[]types.Decimal128{{B0_63: 125, B64_127: 0}, {B0_63: 0, B64_127: 0}},
   417  				[]bool{false, true}),
   418  		},
   419  		{
   420  			info: "int16 to bit",
   421  			inputs: []testutil.FunctionTestInput{
   422  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{125, 126, 0}, []bool{false, false, true}),
   423  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
   424  			},
   425  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false,
   426  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   427  		},
   428  	}
   429  	castInt32ToOthers := []tcTemp{
   430  		// test cast int32 to others.
   431  		{
   432  			info: "int32 to int16",
   433  			inputs: []testutil.FunctionTestInput{
   434  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
   435  					[]int32{125, 126, 0}, []bool{false, false, true}),
   436  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
   437  			},
   438  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
   439  				[]int16{125, 126, 0}, []bool{false, false, true}),
   440  		},
   441  		{
   442  			info: "int32 to int8",
   443  			inputs: []testutil.FunctionTestInput{
   444  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
   445  					[]int32{125, 126, 0}, []bool{false, false, true}),
   446  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
   447  			},
   448  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
   449  				[]int8{125, 126, 0}, []bool{false, false, true}),
   450  		},
   451  		{
   452  			info: "int32 to int64",
   453  			inputs: []testutil.FunctionTestInput{
   454  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
   455  					[]int32{125, 126, 0}, []bool{false, false, true}),
   456  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
   457  			},
   458  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
   459  				[]int64{125, 126, 0}, []bool{false, false, true}),
   460  		},
   461  		{
   462  			info: "int32 to uint8",
   463  			inputs: []testutil.FunctionTestInput{
   464  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
   465  					[]int32{125, 126, 0}, []bool{false, false, true}),
   466  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
   467  			},
   468  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
   469  				[]uint8{125, 126, 0}, []bool{false, false, true}),
   470  		},
   471  		{
   472  			info: "int32 to uint16",
   473  			inputs: []testutil.FunctionTestInput{
   474  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
   475  					[]int32{125, 126, 0}, []bool{false, false, true}),
   476  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
   477  			},
   478  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
   479  				[]uint16{125, 126, 0}, []bool{false, false, true}),
   480  		},
   481  		{
   482  			info: "int32 to uint32",
   483  			inputs: []testutil.FunctionTestInput{
   484  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
   485  					[]int32{125, 126, 0}, []bool{false, false, true}),
   486  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
   487  			},
   488  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
   489  				[]uint32{125, 126, 0}, []bool{false, false, true}),
   490  		},
   491  		{
   492  			info: "int32 to uint64",
   493  			inputs: []testutil.FunctionTestInput{
   494  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
   495  					[]int32{125, 126, 0}, []bool{false, false, true}),
   496  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
   497  			},
   498  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
   499  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   500  		},
   501  		{
   502  			info: "int32 to float32",
   503  			inputs: []testutil.FunctionTestInput{
   504  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
   505  					[]int32{125, 126, 0}, []bool{false, false, true}),
   506  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
   507  			},
   508  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
   509  				[]float32{125, 126, 0}, []bool{false, false, true}),
   510  		},
   511  		{
   512  			info: "int32 to float64",
   513  			inputs: []testutil.FunctionTestInput{
   514  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
   515  					[]int32{125, 126, 0}, []bool{false, false, true}),
   516  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
   517  			},
   518  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
   519  				[]float64{125, 126, 0}, []bool{false, false, true}),
   520  		},
   521  		{
   522  			info: "int32 to decimal128",
   523  			inputs: []testutil.FunctionTestInput{
   524  				testutil.NewFunctionTestInput(types.T_int32.ToType(),
   525  					[]int32{125, 0}, []bool{false, true}),
   526  				testutil.NewFunctionTestInput(types.T_decimal128.ToType(), []types.Decimal128{}, []bool{}),
   527  			},
   528  			expect: testutil.NewFunctionTestResult(types.T_decimal128.ToType(), false,
   529  				[]types.Decimal128{{B0_63: 125, B64_127: 0}, {B0_63: 0, B64_127: 0}},
   530  				[]bool{false, true}),
   531  		},
   532  		{
   533  			info: "int32 to bit",
   534  			inputs: []testutil.FunctionTestInput{
   535  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{125, 126, 0}, []bool{false, false, true}),
   536  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
   537  			},
   538  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false,
   539  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   540  		},
   541  	}
   542  	castInt64ToOthers := []tcTemp{
   543  		// test cast int64 to others.
   544  		{
   545  			info: "int64 to int8",
   546  			inputs: []testutil.FunctionTestInput{
   547  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
   548  					[]int64{125, 126, 0}, []bool{false, false, true}),
   549  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
   550  			},
   551  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
   552  				[]int8{125, 126, 0}, []bool{false, false, true}),
   553  		},
   554  		{
   555  			info: "int64 to int16",
   556  			inputs: []testutil.FunctionTestInput{
   557  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
   558  					[]int64{125, 126, 0}, []bool{false, false, true}),
   559  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
   560  			},
   561  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
   562  				[]int16{125, 126, 0}, []bool{false, false, true}),
   563  		},
   564  		{
   565  			info: "int64 to int32",
   566  			inputs: []testutil.FunctionTestInput{
   567  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
   568  					[]int64{125, 126, 0}, []bool{false, false, true}),
   569  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
   570  			},
   571  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
   572  				[]int32{125, 126, 0}, []bool{false, false, true}),
   573  		},
   574  		{
   575  			info: "int64 to uint8",
   576  			inputs: []testutil.FunctionTestInput{
   577  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
   578  					[]int64{125, 126, 0}, []bool{false, false, true}),
   579  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
   580  			},
   581  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
   582  				[]uint8{125, 126, 0}, []bool{false, false, true}),
   583  		},
   584  		{
   585  			info: "int64 to uint16",
   586  			inputs: []testutil.FunctionTestInput{
   587  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
   588  					[]int64{125, 126, 0}, []bool{false, false, true}),
   589  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
   590  			},
   591  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
   592  				[]uint16{125, 126, 0}, []bool{false, false, true}),
   593  		},
   594  		{
   595  			info: "int64 to uint32",
   596  			inputs: []testutil.FunctionTestInput{
   597  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
   598  					[]int64{125, 126, 0}, []bool{false, false, true}),
   599  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
   600  			},
   601  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
   602  				[]uint32{125, 126, 0}, []bool{false, false, true}),
   603  		},
   604  		{
   605  			info: "int64 to uint64",
   606  			inputs: []testutil.FunctionTestInput{
   607  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
   608  					[]int64{125, 126, 0}, []bool{false, false, true}),
   609  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
   610  			},
   611  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
   612  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   613  		},
   614  		{
   615  			info: "int64 to float32",
   616  			inputs: []testutil.FunctionTestInput{
   617  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
   618  					[]int64{125, 126, 0}, []bool{false, false, true}),
   619  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
   620  			},
   621  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
   622  				[]float32{125, 126, 0}, []bool{false, false, true}),
   623  		},
   624  		{
   625  			info: "int64 to float64",
   626  			inputs: []testutil.FunctionTestInput{
   627  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
   628  					[]int64{125, 126, 0}, []bool{false, false, true}),
   629  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
   630  			},
   631  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
   632  				[]float64{125, 126, 0}, []bool{false, false, true}),
   633  		},
   634  		{
   635  			info: "int64 to decimal128",
   636  			inputs: []testutil.FunctionTestInput{
   637  				testutil.NewFunctionTestInput(types.T_int64.ToType(),
   638  					[]int64{125, 0}, []bool{false, true}),
   639  				testutil.NewFunctionTestInput(types.T_decimal128.ToType(), []types.Decimal128{}, []bool{}),
   640  			},
   641  			expect: testutil.NewFunctionTestResult(types.T_decimal128.ToType(), false,
   642  				[]types.Decimal128{{B0_63: 125, B64_127: 0}, {B0_63: 0, B64_127: 0}},
   643  				[]bool{false, true}),
   644  		},
   645  		{
   646  			info: "int64 to bit",
   647  			inputs: []testutil.FunctionTestInput{
   648  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{125, 126, 0}, []bool{false, false, true}),
   649  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
   650  			},
   651  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false,
   652  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   653  		},
   654  	}
   655  	castUint8ToOthers := []tcTemp{
   656  		// test cast uint8 to others.
   657  		{
   658  			info: "uint8 to int16",
   659  			inputs: []testutil.FunctionTestInput{
   660  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
   661  					[]uint8{125, 126, 0}, []bool{false, false, true}),
   662  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
   663  			},
   664  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
   665  				[]int16{125, 126, 0}, []bool{false, false, true}),
   666  		},
   667  		{
   668  			info: "uint8 to int32",
   669  			inputs: []testutil.FunctionTestInput{
   670  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
   671  					[]uint8{125, 126, 0}, []bool{false, false, true}),
   672  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
   673  			},
   674  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
   675  				[]int32{125, 126, 0}, []bool{false, false, true}),
   676  		},
   677  		{
   678  			info: "uint8 to int64",
   679  			inputs: []testutil.FunctionTestInput{
   680  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
   681  					[]uint8{125, 126, 0}, []bool{false, false, true}),
   682  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
   683  			},
   684  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
   685  				[]int64{125, 126, 0}, []bool{false, false, true}),
   686  		},
   687  		{
   688  			info: "uint8 to int8",
   689  			inputs: []testutil.FunctionTestInput{
   690  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
   691  					[]uint8{125, 126, 0}, []bool{false, false, true}),
   692  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
   693  			},
   694  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
   695  				[]int8{125, 126, 0}, []bool{false, false, true}),
   696  		},
   697  		{
   698  			info: "uint8 to uint16",
   699  			inputs: []testutil.FunctionTestInput{
   700  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
   701  					[]uint8{125, 126, 0}, []bool{false, false, true}),
   702  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
   703  			},
   704  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
   705  				[]uint16{125, 126, 0}, []bool{false, false, true}),
   706  		},
   707  		{
   708  			info: "uint8 to uint32",
   709  			inputs: []testutil.FunctionTestInput{
   710  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
   711  					[]uint8{125, 126, 0}, []bool{false, false, true}),
   712  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
   713  			},
   714  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
   715  				[]uint32{125, 126, 0}, []bool{false, false, true}),
   716  		},
   717  		{
   718  			info: "uint8 to uint64",
   719  			inputs: []testutil.FunctionTestInput{
   720  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
   721  					[]uint8{125, 126, 0}, []bool{false, false, true}),
   722  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
   723  			},
   724  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
   725  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   726  		},
   727  		{
   728  			info: "uint8 to float32",
   729  			inputs: []testutil.FunctionTestInput{
   730  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
   731  					[]uint8{125, 126, 0}, []bool{false, false, true}),
   732  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
   733  			},
   734  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
   735  				[]float32{125, 126, 0}, []bool{false, false, true}),
   736  		},
   737  		{
   738  			info: "uint8 to float64",
   739  			inputs: []testutil.FunctionTestInput{
   740  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
   741  					[]uint8{125, 126, 0}, []bool{false, false, true}),
   742  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
   743  			},
   744  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
   745  				[]float64{125, 126, 0}, []bool{false, false, true}),
   746  		},
   747  		{
   748  			info: "uint8 to decimal128",
   749  			inputs: []testutil.FunctionTestInput{
   750  				testutil.NewFunctionTestInput(types.T_uint8.ToType(),
   751  					[]uint8{125, 0}, []bool{false, true}),
   752  				testutil.NewFunctionTestInput(types.T_decimal128.ToType(), []types.Decimal128{}, []bool{}),
   753  			},
   754  			expect: testutil.NewFunctionTestResult(types.T_decimal128.ToType(), false,
   755  				[]types.Decimal128{{B0_63: 125, B64_127: 0}, {B0_63: 0, B64_127: 0}},
   756  				[]bool{false, true}),
   757  		},
   758  		{
   759  			info: "uint8 to bit",
   760  			inputs: []testutil.FunctionTestInput{
   761  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{125, 126, 0}, []bool{false, false, true}),
   762  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
   763  			},
   764  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false,
   765  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   766  		},
   767  	}
   768  	castUint16ToOthers := []tcTemp{
   769  		// test cast uint16 to others.
   770  		{
   771  			info: "uint16 to int8",
   772  			inputs: []testutil.FunctionTestInput{
   773  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
   774  					[]uint16{125, 126, 0}, []bool{false, false, true}),
   775  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
   776  			},
   777  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
   778  				[]int8{125, 126, 0}, []bool{false, false, true}),
   779  		},
   780  		{
   781  			info: "uint16 to int32",
   782  			inputs: []testutil.FunctionTestInput{
   783  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
   784  					[]uint16{125, 126, 0}, []bool{false, false, true}),
   785  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
   786  			},
   787  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
   788  				[]int32{125, 126, 0}, []bool{false, false, true}),
   789  		},
   790  		{
   791  			info: "uint16 to int64",
   792  			inputs: []testutil.FunctionTestInput{
   793  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
   794  					[]uint16{125, 126, 0}, []bool{false, false, true}),
   795  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
   796  			},
   797  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
   798  				[]int64{125, 126, 0}, []bool{false, false, true}),
   799  		},
   800  		{
   801  			info: "uint16 to uint8",
   802  			inputs: []testutil.FunctionTestInput{
   803  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
   804  					[]uint16{125, 126, 0}, []bool{false, false, true}),
   805  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
   806  			},
   807  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
   808  				[]uint8{125, 126, 0}, []bool{false, false, true}),
   809  		},
   810  		{
   811  			info: "uint16 to int16",
   812  			inputs: []testutil.FunctionTestInput{
   813  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
   814  					[]uint16{125, 126, 0}, []bool{false, false, true}),
   815  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
   816  			},
   817  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
   818  				[]int16{125, 126, 0}, []bool{false, false, true}),
   819  		},
   820  		{
   821  			info: "uint16 to uint32",
   822  			inputs: []testutil.FunctionTestInput{
   823  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
   824  					[]uint16{125, 126, 0}, []bool{false, false, true}),
   825  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
   826  			},
   827  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
   828  				[]uint32{125, 126, 0}, []bool{false, false, true}),
   829  		},
   830  		{
   831  			info: "uint16 to uint64",
   832  			inputs: []testutil.FunctionTestInput{
   833  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
   834  					[]uint16{125, 126, 0}, []bool{false, false, true}),
   835  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
   836  			},
   837  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
   838  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   839  		},
   840  		{
   841  			info: "uint16 to float32",
   842  			inputs: []testutil.FunctionTestInput{
   843  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
   844  					[]uint16{125, 126, 0}, []bool{false, false, true}),
   845  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
   846  			},
   847  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
   848  				[]float32{125, 126, 0}, []bool{false, false, true}),
   849  		},
   850  		{
   851  			info: "uint16 to float64",
   852  			inputs: []testutil.FunctionTestInput{
   853  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
   854  					[]uint16{125, 126, 0}, []bool{false, false, true}),
   855  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
   856  			},
   857  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
   858  				[]float64{125, 126, 0}, []bool{false, false, true}),
   859  		},
   860  		{
   861  			info: "uint16 to decimal128",
   862  			inputs: []testutil.FunctionTestInput{
   863  				testutil.NewFunctionTestInput(types.T_uint16.ToType(),
   864  					[]uint16{125, 0}, []bool{false, true}),
   865  				testutil.NewFunctionTestInput(types.T_decimal128.ToType(), []types.Decimal128{}, []bool{}),
   866  			},
   867  			expect: testutil.NewFunctionTestResult(types.T_decimal128.ToType(), false,
   868  				[]types.Decimal128{{B0_63: 125, B64_127: 0}, {B0_63: 0, B64_127: 0}},
   869  				[]bool{false, true}),
   870  		},
   871  		{
   872  			info: "uint16 to bit",
   873  			inputs: []testutil.FunctionTestInput{
   874  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{125, 126, 0}, []bool{false, false, true}),
   875  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
   876  			},
   877  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false,
   878  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   879  		},
   880  	}
   881  	castUint32ToOthers := []tcTemp{
   882  		// test cast uint32 to others.
   883  		{
   884  			info: "uint32 to int16",
   885  			inputs: []testutil.FunctionTestInput{
   886  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   887  					[]uint32{125, 126, 0}, []bool{false, false, true}),
   888  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
   889  			},
   890  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
   891  				[]int16{125, 126, 0}, []bool{false, false, true}),
   892  		},
   893  		{
   894  			info: "uint32 to int8",
   895  			inputs: []testutil.FunctionTestInput{
   896  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   897  					[]uint32{125, 126, 0}, []bool{false, false, true}),
   898  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
   899  			},
   900  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
   901  				[]int8{125, 126, 0}, []bool{false, false, true}),
   902  		},
   903  		{
   904  			info: "uint32 to int64",
   905  			inputs: []testutil.FunctionTestInput{
   906  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   907  					[]uint32{125, 126, 0}, []bool{false, false, true}),
   908  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
   909  			},
   910  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
   911  				[]int64{125, 126, 0}, []bool{false, false, true}),
   912  		},
   913  		{
   914  			info: "uint32 to uint8",
   915  			inputs: []testutil.FunctionTestInput{
   916  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   917  					[]uint32{125, 126, 0}, []bool{false, false, true}),
   918  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
   919  			},
   920  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
   921  				[]uint8{125, 126, 0}, []bool{false, false, true}),
   922  		},
   923  		{
   924  			info: "uint32 to uint16",
   925  			inputs: []testutil.FunctionTestInput{
   926  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   927  					[]uint32{125, 126, 0}, []bool{false, false, true}),
   928  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
   929  			},
   930  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
   931  				[]uint16{125, 126, 0}, []bool{false, false, true}),
   932  		},
   933  		{
   934  			info: "uint32 to int32",
   935  			inputs: []testutil.FunctionTestInput{
   936  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   937  					[]uint32{125, 126, 0}, []bool{false, false, true}),
   938  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
   939  			},
   940  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
   941  				[]int32{125, 126, 0}, []bool{false, false, true}),
   942  		},
   943  		{
   944  			info: "uint32 to uint64",
   945  			inputs: []testutil.FunctionTestInput{
   946  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   947  					[]uint32{125, 126, 0}, []bool{false, false, true}),
   948  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
   949  			},
   950  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
   951  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   952  		},
   953  		{
   954  			info: "uint32 to float32",
   955  			inputs: []testutil.FunctionTestInput{
   956  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   957  					[]uint32{125, 126, 0}, []bool{false, false, true}),
   958  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
   959  			},
   960  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
   961  				[]float32{125, 126, 0}, []bool{false, false, true}),
   962  		},
   963  		{
   964  			info: "uint32 to float64",
   965  			inputs: []testutil.FunctionTestInput{
   966  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   967  					[]uint32{125, 126, 0}, []bool{false, false, true}),
   968  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
   969  			},
   970  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
   971  				[]float64{125, 126, 0}, []bool{false, false, true}),
   972  		},
   973  		{
   974  			info: "uint32 to decimal128",
   975  			inputs: []testutil.FunctionTestInput{
   976  				testutil.NewFunctionTestInput(types.T_uint32.ToType(),
   977  					[]uint32{125, 0}, []bool{false, true}),
   978  				testutil.NewFunctionTestInput(types.T_decimal128.ToType(), []types.Decimal128{}, []bool{}),
   979  			},
   980  			expect: testutil.NewFunctionTestResult(types.T_decimal128.ToType(), false,
   981  				[]types.Decimal128{{B0_63: 125, B64_127: 0}, {B0_63: 0, B64_127: 0}},
   982  				[]bool{false, true}),
   983  		},
   984  		{
   985  			info: "uint32 to bit",
   986  			inputs: []testutil.FunctionTestInput{
   987  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{125, 126, 0}, []bool{false, false, true}),
   988  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
   989  			},
   990  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false,
   991  				[]uint64{125, 126, 0}, []bool{false, false, true}),
   992  		},
   993  	}
   994  	castUint64ToOthers := []tcTemp{
   995  		// test cast uint64 to others.
   996  		{
   997  			info: "uint64 to int8",
   998  			inputs: []testutil.FunctionTestInput{
   999  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
  1000  					[]uint64{125, 126, 0}, []bool{false, false, true}),
  1001  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
  1002  			},
  1003  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
  1004  				[]int8{125, 126, 0}, []bool{false, false, true}),
  1005  		},
  1006  		{
  1007  			info: "uint64 to int16",
  1008  			inputs: []testutil.FunctionTestInput{
  1009  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
  1010  					[]uint64{125, 126, 0}, []bool{false, false, true}),
  1011  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
  1012  			},
  1013  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
  1014  				[]int16{125, 126, 0}, []bool{false, false, true}),
  1015  		},
  1016  		{
  1017  			info: "uint64 to int32",
  1018  			inputs: []testutil.FunctionTestInput{
  1019  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
  1020  					[]uint64{125, 126, 0}, []bool{false, false, true}),
  1021  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
  1022  			},
  1023  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
  1024  				[]int32{125, 126, 0}, []bool{false, false, true}),
  1025  		},
  1026  		{
  1027  			info: "uint64 to uint8",
  1028  			inputs: []testutil.FunctionTestInput{
  1029  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
  1030  					[]uint64{125, 126, 0}, []bool{false, false, true}),
  1031  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
  1032  			},
  1033  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
  1034  				[]uint8{125, 126, 0}, []bool{false, false, true}),
  1035  		},
  1036  		{
  1037  			info: "uint64 to uint16",
  1038  			inputs: []testutil.FunctionTestInput{
  1039  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
  1040  					[]uint64{125, 126, 0}, []bool{false, false, true}),
  1041  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
  1042  			},
  1043  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
  1044  				[]uint16{125, 126, 0}, []bool{false, false, true}),
  1045  		},
  1046  		{
  1047  			info: "uint64 to uint32",
  1048  			inputs: []testutil.FunctionTestInput{
  1049  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
  1050  					[]uint64{125, 126, 0}, []bool{false, false, true}),
  1051  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
  1052  			},
  1053  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
  1054  				[]uint32{125, 126, 0}, []bool{false, false, true}),
  1055  		},
  1056  		{
  1057  			info: "uint64 to int64",
  1058  			inputs: []testutil.FunctionTestInput{
  1059  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
  1060  					[]uint64{125, 126, 0}, []bool{false, false, true}),
  1061  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
  1062  			},
  1063  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
  1064  				[]int64{125, 126, 0}, []bool{false, false, true}),
  1065  		},
  1066  		{
  1067  			info: "uint64 to float32",
  1068  			inputs: []testutil.FunctionTestInput{
  1069  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
  1070  					[]uint64{125, 126, 0}, []bool{false, false, true}),
  1071  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
  1072  			},
  1073  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
  1074  				[]float32{125, 126, 0}, []bool{false, false, true}),
  1075  		},
  1076  		{
  1077  			info: "uint64 to float64",
  1078  			inputs: []testutil.FunctionTestInput{
  1079  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
  1080  					[]uint64{125, 126, 0}, []bool{false, false, true}),
  1081  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
  1082  			},
  1083  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
  1084  				[]float64{125, 126, 0}, []bool{false, false, true}),
  1085  		},
  1086  		{
  1087  			info: "uint64 to decimal128",
  1088  			inputs: []testutil.FunctionTestInput{
  1089  				testutil.NewFunctionTestInput(types.T_uint64.ToType(),
  1090  					[]uint64{125, 0}, []bool{false, true}),
  1091  				testutil.NewFunctionTestInput(types.T_decimal128.ToType(), []types.Decimal128{}, []bool{}),
  1092  			},
  1093  			expect: testutil.NewFunctionTestResult(types.T_decimal128.ToType(), false,
  1094  				[]types.Decimal128{{B0_63: 125, B64_127: 0}, {B0_63: 0, B64_127: 0}},
  1095  				[]bool{false, true}),
  1096  		},
  1097  		{
  1098  			info: "uint64 to bit",
  1099  			inputs: []testutil.FunctionTestInput{
  1100  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{125, 126, 0}, []bool{false, false, true}),
  1101  				testutil.NewFunctionTestInput(types.New(types.T_bit, 5, 0), []uint64{}, []bool{}),
  1102  			},
  1103  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), true, []uint64{}, []bool{}),
  1104  		},
  1105  	}
  1106  	castFloat32ToOthers := []tcTemp{
  1107  		// test cast float32 to others.
  1108  		{
  1109  			info: "float32 to int8",
  1110  			inputs: []testutil.FunctionTestInput{
  1111  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1112  					[]float32{125, 126, 0}, []bool{false, false, true}),
  1113  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
  1114  			},
  1115  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
  1116  				[]int8{125, 126, 0}, []bool{false, false, true}),
  1117  		},
  1118  		{
  1119  			info: "float32 to int16",
  1120  			inputs: []testutil.FunctionTestInput{
  1121  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1122  					[]float32{125, 126, 0}, []bool{false, false, true}),
  1123  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
  1124  			},
  1125  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
  1126  				[]int16{125, 126, 0}, []bool{false, false, true}),
  1127  		},
  1128  		{
  1129  			info: "float32 to int32",
  1130  			inputs: []testutil.FunctionTestInput{
  1131  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1132  					[]float32{125, 126, 0}, []bool{false, false, true}),
  1133  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
  1134  			},
  1135  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
  1136  				[]int32{125, 126, 0}, []bool{false, false, true}),
  1137  		},
  1138  		{
  1139  			info: "float32 to uint8",
  1140  			inputs: []testutil.FunctionTestInput{
  1141  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1142  					[]float32{125, 126, 0}, []bool{false, false, true}),
  1143  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
  1144  			},
  1145  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
  1146  				[]uint8{125, 126, 0}, []bool{false, false, true}),
  1147  		},
  1148  		{
  1149  			info: "float32 to uint16",
  1150  			inputs: []testutil.FunctionTestInput{
  1151  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1152  					[]float32{125, 126, 0}, []bool{false, false, true}),
  1153  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
  1154  			},
  1155  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
  1156  				[]uint16{125, 126, 0}, []bool{false, false, true}),
  1157  		},
  1158  		{
  1159  			info: "float32 to uint32",
  1160  			inputs: []testutil.FunctionTestInput{
  1161  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1162  					[]float32{125, 126, 0}, []bool{false, false, true}),
  1163  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
  1164  			},
  1165  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
  1166  				[]uint32{125, 126, 0}, []bool{false, false, true}),
  1167  		},
  1168  		{
  1169  			info: "float32 to int64",
  1170  			inputs: []testutil.FunctionTestInput{
  1171  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1172  					[]float32{125, 126, 0}, []bool{false, false, true}),
  1173  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
  1174  			},
  1175  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
  1176  				[]int64{125, 126, 0}, []bool{false, false, true}),
  1177  		},
  1178  		{
  1179  			info: "float32 to float64",
  1180  			inputs: []testutil.FunctionTestInput{
  1181  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1182  					[]float32{125, 126, 0}, []bool{false, false, true}),
  1183  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
  1184  			},
  1185  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
  1186  				[]float64{125, 126, 0}, []bool{false, false, true}),
  1187  		},
  1188  		{
  1189  			info: "float32 to uint64",
  1190  			inputs: []testutil.FunctionTestInput{
  1191  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1192  					[]float32{125, 126, 0}, []bool{false, false, true}),
  1193  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
  1194  			},
  1195  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
  1196  				[]uint64{125, 126, 0}, []bool{false, false, true}),
  1197  		},
  1198  		{
  1199  			info: "float32 to str type",
  1200  			inputs: []testutil.FunctionTestInput{
  1201  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1202  					[]float32{23.56, 126, 0}, []bool{false, false, true}),
  1203  				testutil.NewFunctionTestInput(types.T_char.ToType(), []string{}, []bool{}),
  1204  			},
  1205  			expect: testutil.NewFunctionTestResult(types.T_char.ToType(), false,
  1206  				[]string{"23.56", "126", "0"}, []bool{false, false, true}),
  1207  		},
  1208  		{
  1209  			info: "float32 to decimal128",
  1210  			inputs: []testutil.FunctionTestInput{
  1211  				testutil.NewFunctionTestInput(types.T_float32.ToType(),
  1212  					[]float32{125.1, 0}, []bool{false, true}),
  1213  				testutil.NewFunctionTestInput(types.New(types.T_decimal128, 8, 1), []types.Decimal128{}, []bool{}),
  1214  			},
  1215  			expect: testutil.NewFunctionTestResult(types.New(types.T_decimal128, 8, 1), false,
  1216  				[]types.Decimal128{f1251ToDec128, {B0_63: 0, B64_127: 0}},
  1217  				[]bool{false, true}),
  1218  		},
  1219  		{
  1220  			info: "float32 to bit",
  1221  			inputs: []testutil.FunctionTestInput{
  1222  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{125.4999, 125.55555, 0}, []bool{false, false, true}),
  1223  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
  1224  			},
  1225  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false,
  1226  				[]uint64{125, 126, 0}, []bool{false, false, true}),
  1227  		},
  1228  	}
  1229  	castFloat64ToOthers := []tcTemp{
  1230  		// test cast float64 to others.
  1231  		{
  1232  			info: "float64 to int8",
  1233  			inputs: []testutil.FunctionTestInput{
  1234  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1235  					[]float64{125, 126, 0}, []bool{false, false, true}),
  1236  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
  1237  			},
  1238  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
  1239  				[]int8{125, 126, 0}, []bool{false, false, true}),
  1240  		},
  1241  		{
  1242  			info: "float64 to int16",
  1243  			inputs: []testutil.FunctionTestInput{
  1244  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1245  					[]float64{125, 126, 0}, []bool{false, false, true}),
  1246  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
  1247  			},
  1248  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
  1249  				[]int16{125, 126, 0}, []bool{false, false, true}),
  1250  		},
  1251  		{
  1252  			info: "float64 to int32",
  1253  			inputs: []testutil.FunctionTestInput{
  1254  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1255  					[]float64{125, 126, 0}, []bool{false, false, true}),
  1256  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
  1257  			},
  1258  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
  1259  				[]int32{125, 126, 0}, []bool{false, false, true}),
  1260  		},
  1261  		{
  1262  			info: "float64 to uint8",
  1263  			inputs: []testutil.FunctionTestInput{
  1264  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1265  					[]float64{125, 126, 0}, []bool{false, false, true}),
  1266  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
  1267  			},
  1268  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
  1269  				[]uint8{125, 126, 0}, []bool{false, false, true}),
  1270  		},
  1271  		{
  1272  			info: "float64 to uint16",
  1273  			inputs: []testutil.FunctionTestInput{
  1274  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1275  					[]float64{125, 126, 0}, []bool{false, false, true}),
  1276  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
  1277  			},
  1278  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
  1279  				[]uint16{125, 126, 0}, []bool{false, false, true}),
  1280  		},
  1281  		{
  1282  			info: "float64 to uint32",
  1283  			inputs: []testutil.FunctionTestInput{
  1284  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1285  					[]float64{125, 126, 0}, []bool{false, false, true}),
  1286  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
  1287  			},
  1288  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
  1289  				[]uint32{125, 126, 0}, []bool{false, false, true}),
  1290  		},
  1291  		{
  1292  			info: "float64 to int64",
  1293  			inputs: []testutil.FunctionTestInput{
  1294  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1295  					[]float64{125, 126, 0}, []bool{false, false, true}),
  1296  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
  1297  			},
  1298  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
  1299  				[]int64{125, 126, 0}, []bool{false, false, true}),
  1300  		},
  1301  		{
  1302  			info: "float64 to float32",
  1303  			inputs: []testutil.FunctionTestInput{
  1304  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1305  					[]float64{125, 126, 0}, []bool{false, false, true}),
  1306  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
  1307  			},
  1308  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
  1309  				[]float32{125, 126, 0}, []bool{false, false, true}),
  1310  		},
  1311  		{
  1312  			info: "float64 to uint64",
  1313  			inputs: []testutil.FunctionTestInput{
  1314  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1315  					[]float64{125, 126, 0}, []bool{false, false, true}),
  1316  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
  1317  			},
  1318  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
  1319  				[]uint64{125, 126, 0}, []bool{false, false, true}),
  1320  		},
  1321  		{
  1322  			info: "float64 to str type",
  1323  			inputs: []testutil.FunctionTestInput{
  1324  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1325  					[]float64{23.56, 126, 0}, []bool{false, false, true}),
  1326  				testutil.NewFunctionTestInput(types.T_char.ToType(), []string{}, []bool{}),
  1327  			},
  1328  			expect: testutil.NewFunctionTestResult(types.T_char.ToType(), false,
  1329  				[]string{"23.56", "126", "0"}, []bool{false, false, true}),
  1330  		},
  1331  		{
  1332  			info: "float64 to decimal128",
  1333  			inputs: []testutil.FunctionTestInput{
  1334  				testutil.NewFunctionTestInput(types.T_float64.ToType(),
  1335  					[]float64{125.1, 0}, []bool{false, true}),
  1336  				testutil.NewFunctionTestInput(types.New(types.T_decimal128, 8, 1), []types.Decimal128{}, []bool{}),
  1337  			},
  1338  			expect: testutil.NewFunctionTestResult(types.New(types.T_decimal128, 8, 1), false,
  1339  				[]types.Decimal128{f1251ToDec128, {B0_63: 0, B64_127: 0}},
  1340  				[]bool{false, true}),
  1341  		},
  1342  		{
  1343  			info: "float64 to bit",
  1344  			inputs: []testutil.FunctionTestInput{
  1345  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{125.4999, 125.55555, 0}, []bool{false, false, true}),
  1346  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
  1347  			},
  1348  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false,
  1349  				[]uint64{125, 126, 0}, []bool{false, false, true}),
  1350  		},
  1351  	}
  1352  	castStrToOthers := []tcTemp{
  1353  		{
  1354  			info: "str type to int8",
  1355  			inputs: []testutil.FunctionTestInput{
  1356  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1357  					[]string{"15", "16"}, nil),
  1358  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
  1359  			},
  1360  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), false,
  1361  				[]int8{15, 16}, []bool{false, false}),
  1362  		},
  1363  		{
  1364  			info: "str type to int16",
  1365  			inputs: []testutil.FunctionTestInput{
  1366  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1367  					[]string{"15", "16"}, nil),
  1368  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
  1369  			},
  1370  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
  1371  				[]int16{15, 16}, []bool{false, false}),
  1372  		},
  1373  		{
  1374  			info: "str type to int32",
  1375  			inputs: []testutil.FunctionTestInput{
  1376  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1377  					[]string{"15", "16"}, nil),
  1378  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
  1379  			},
  1380  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
  1381  				[]int32{15, 16}, []bool{false, false}),
  1382  		},
  1383  		{
  1384  			info: "str type to int64",
  1385  			inputs: []testutil.FunctionTestInput{
  1386  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1387  					[]string{"1501", "16", ""}, []bool{false, false, true}),
  1388  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
  1389  			},
  1390  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
  1391  				[]int64{1501, 16, 0}, []bool{false, false, true}),
  1392  		},
  1393  		{
  1394  			info: "str type to uint8",
  1395  			inputs: []testutil.FunctionTestInput{
  1396  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1397  					[]string{"15", "16"}, nil),
  1398  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
  1399  			},
  1400  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
  1401  				[]uint8{15, 16}, []bool{false, false}),
  1402  		},
  1403  		{
  1404  			info: "str type to uint16",
  1405  			inputs: []testutil.FunctionTestInput{
  1406  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1407  					[]string{"15", "16"}, nil),
  1408  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
  1409  			},
  1410  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
  1411  				[]uint16{15, 16}, []bool{false, false}),
  1412  		},
  1413  		{
  1414  			info: "str type to uint32",
  1415  			inputs: []testutil.FunctionTestInput{
  1416  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1417  					[]string{"15", "16"}, nil),
  1418  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
  1419  			},
  1420  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
  1421  				[]uint32{15, 16}, []bool{false, false}),
  1422  		},
  1423  		{
  1424  			info: "str type to uint64",
  1425  			inputs: []testutil.FunctionTestInput{
  1426  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1427  					[]string{"1501", "16", ""}, []bool{false, false, true}),
  1428  				testutil.NewFunctionTestInput(types.T_uint64.ToType(), []uint64{}, []bool{}),
  1429  			},
  1430  			expect: testutil.NewFunctionTestResult(types.T_uint64.ToType(), false,
  1431  				[]uint64{1501, 16, 0}, []bool{false, false, true}),
  1432  		},
  1433  		{
  1434  			info: "str type to float32",
  1435  			inputs: []testutil.FunctionTestInput{
  1436  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1437  					[]string{"15", "16"}, nil),
  1438  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
  1439  			},
  1440  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
  1441  				[]float32{15, 16}, []bool{false, false}),
  1442  		},
  1443  		{
  1444  			info: "str type to float64",
  1445  			inputs: []testutil.FunctionTestInput{
  1446  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1447  					[]string{"1501.12", "16", ""}, []bool{false, false, true}),
  1448  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
  1449  			},
  1450  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
  1451  				[]float64{1501.12, 16, 0}, []bool{false, false, true}),
  1452  		},
  1453  		{
  1454  			info: "str type to str type",
  1455  			inputs: []testutil.FunctionTestInput{
  1456  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1457  					[]string{"1501.12", "16", ""}, []bool{false, false, true}),
  1458  				testutil.NewFunctionTestInput(types.T_text.ToType(), []string{}, []bool{}),
  1459  			},
  1460  			expect: testutil.NewFunctionTestResult(types.T_text.ToType(), false,
  1461  				[]string{"1501.12", "16", ""}, []bool{false, false, true}),
  1462  		},
  1463  		{
  1464  			info: "str type to date",
  1465  			inputs: []testutil.FunctionTestInput{
  1466  				testutil.NewFunctionTestInput(types.T_varchar.ToType(),
  1467  					[]string{"2004-04-03", "2004-04-03", "2021-10-03"},
  1468  					[]bool{false, false, false}),
  1469  				testutil.NewFunctionTestInput(types.T_date.ToType(), []types.Date{}, []bool{}),
  1470  			},
  1471  			expect: testutil.NewFunctionTestResult(
  1472  				types.T_date.ToType(), false,
  1473  				[]types.Date{
  1474  					s01date, s01date, s02date,
  1475  				},
  1476  				[]bool{false, false, false}),
  1477  		},
  1478  		{
  1479  			info: "str type to vecf32",
  1480  			inputs: []testutil.FunctionTestInput{
  1481  				testutil.NewFunctionTestInput(types.T_varchar.ToType(), []string{"[1,2,3]", "[4,5,6]"}, nil),
  1482  				testutil.NewFunctionTestInput(types.T_array_float32.ToType(), [][]float32{}, []bool{}),
  1483  			},
  1484  			expect: testutil.NewFunctionTestResult(types.T_array_float32.ToType(), false, [][]float32{{1, 2, 3}, {4, 5, 6}}, []bool{false, false}),
  1485  		},
  1486  		{
  1487  			info: "str type to vecf64",
  1488  			inputs: []testutil.FunctionTestInput{
  1489  				testutil.NewFunctionTestInput(types.T_varchar.ToType(), []string{"[1,2,3]", "[4,5,6]"}, nil),
  1490  				testutil.NewFunctionTestInput(types.T_array_float64.ToType(), [][]float64{}, []bool{}),
  1491  			},
  1492  			expect: testutil.NewFunctionTestResult(types.T_array_float64.ToType(), false, [][]float64{{1, 2, 3}, {4, 5, 6}}, []bool{false, false}),
  1493  		},
  1494  		{
  1495  			info: "str type to bit",
  1496  			inputs: []testutil.FunctionTestInput{
  1497  				testutil.NewFunctionTestInput(types.T_varchar.ToType(), []string{"15", "ab"}, nil),
  1498  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{}, []bool{}),
  1499  			},
  1500  			expect: testutil.NewFunctionTestResult(types.T_bit.ToType(), false,
  1501  				[]uint64{12597, 24930}, []bool{false, false}),
  1502  		},
  1503  	}
  1504  	castDecToOthers := []tcTemp{
  1505  		{
  1506  			info: "decimal64 to decimal128",
  1507  			inputs: []testutil.FunctionTestInput{
  1508  				testutil.NewFunctionTestInput(
  1509  					types.New(types.T_decimal64, 10, 0),
  1510  					[]types.Decimal64{types.Decimal64(333333000)}, nil),
  1511  				testutil.NewFunctionTestInput(
  1512  					types.New(types.T_decimal128, 20, 0),
  1513  					[]types.Decimal128{}, nil),
  1514  			},
  1515  			expect: testutil.NewFunctionTestResult(
  1516  				types.New(types.T_decimal128, 20, 0), false,
  1517  				[]types.Decimal128{{B0_63: 333333000, B64_127: 0}}, nil),
  1518  		},
  1519  		{
  1520  			info: "decimal64(10,5) to decimal64(10, 4)",
  1521  			inputs: []testutil.FunctionTestInput{
  1522  				testutil.NewFunctionTestInput(
  1523  					types.New(types.T_decimal64, 10, 5),
  1524  					[]types.Decimal64{types.Decimal64(33333300)}, nil),
  1525  				testutil.NewFunctionTestInput(
  1526  					types.New(types.T_decimal64, 10, 4),
  1527  					[]types.Decimal64{0}, nil),
  1528  			},
  1529  			expect: testutil.NewFunctionTestResult(
  1530  				types.New(types.T_decimal64, 10, 4), false,
  1531  				[]types.Decimal64{types.Decimal64(3333330)}, nil),
  1532  		},
  1533  		{
  1534  			info: "decimal64(10,5) to decimal128(20, 5)",
  1535  			inputs: []testutil.FunctionTestInput{
  1536  				testutil.NewFunctionTestInput(
  1537  					types.New(types.T_decimal64, 10, 5),
  1538  					[]types.Decimal64{types.Decimal64(333333000)}, nil),
  1539  				testutil.NewFunctionTestInput(
  1540  					types.New(types.T_decimal128, 20, 5),
  1541  					[]types.Decimal128{}, nil),
  1542  			},
  1543  			expect: testutil.NewFunctionTestResult(
  1544  				types.New(types.T_decimal128, 20, 5), false,
  1545  				[]types.Decimal128{{B0_63: 333333000, B64_127: 0}}, nil),
  1546  		},
  1547  		{
  1548  			info: "decimal128(20,5) to decimal128(20, 4)",
  1549  			inputs: []testutil.FunctionTestInput{
  1550  				testutil.NewFunctionTestInput(
  1551  					types.New(types.T_decimal128, 20, 5),
  1552  					[]types.Decimal128{{B0_63: 333333000, B64_127: 0}}, nil),
  1553  				testutil.NewFunctionTestInput(
  1554  					types.New(types.T_decimal128, 20, 4),
  1555  					[]types.Decimal128{}, nil),
  1556  			},
  1557  			expect: testutil.NewFunctionTestResult(
  1558  				types.New(types.T_decimal128, 20, 4), false,
  1559  				[]types.Decimal128{{B0_63: 33333300, B64_127: 0}}, nil),
  1560  		},
  1561  		{
  1562  			info: "decimal64 to str type",
  1563  			inputs: []testutil.FunctionTestInput{
  1564  				testutil.NewFunctionTestInput(
  1565  					types.New(types.T_decimal64, 10, 5),
  1566  					[]types.Decimal64{types.Decimal64(1234)}, nil),
  1567  				testutil.NewFunctionTestInput(
  1568  					types.T_varchar.ToType(),
  1569  					[]string{}, nil),
  1570  			},
  1571  			expect: testutil.NewFunctionTestResult(
  1572  				types.T_varchar.ToType(), false,
  1573  				[]string{"0.01234"}, nil),
  1574  		},
  1575  		{
  1576  			info: "decimal128 to str type",
  1577  			inputs: []testutil.FunctionTestInput{
  1578  				testutil.NewFunctionTestInput(
  1579  					types.New(types.T_decimal128, 20, 2),
  1580  					[]types.Decimal128{{B0_63: 1234, B64_127: 0}}, nil),
  1581  				testutil.NewFunctionTestInput(
  1582  					types.T_varchar.ToType(),
  1583  					[]string{}, nil),
  1584  			},
  1585  			expect: testutil.NewFunctionTestResult(
  1586  				types.T_varchar.ToType(), false,
  1587  				[]string{"12.34"}, nil),
  1588  		},
  1589  	}
  1590  	castTimestampToOthers := []tcTemp{
  1591  		{
  1592  			info: "timestamp to str type",
  1593  			inputs: []testutil.FunctionTestInput{
  1594  				testutil.NewFunctionTestInput(
  1595  					types.T_timestamp.ToType(),
  1596  					[]types.Timestamp{s01ts}, nil),
  1597  				testutil.NewFunctionTestInput(
  1598  					types.T_varchar.ToType(), []string{}, nil),
  1599  			},
  1600  			expect: testutil.NewFunctionTestResult(
  1601  				types.T_varchar.ToType(), false,
  1602  				[]string{"2020-08-23 11:52:21"}, nil),
  1603  		},
  1604  	}
  1605  
  1606  	castArrayFloat32ToOthers := []tcTemp{
  1607  		{
  1608  			info: "vecf32 type to vecf64",
  1609  			inputs: []testutil.FunctionTestInput{
  1610  				testutil.NewFunctionTestInput(types.T_array_float32.ToType(), [][]float32{{1, 2, 3}, {4, 5, 6}}, nil),
  1611  				testutil.NewFunctionTestInput(types.T_array_float64.ToType(), [][]float64{}, []bool{}),
  1612  			},
  1613  			expect: testutil.NewFunctionTestResult(types.T_array_float64.ToType(), false, [][]float64{{1, 2, 3}, {4, 5, 6}}, []bool{false, false}),
  1614  		},
  1615  	}
  1616  
  1617  	castArrayFloat64ToOthers := []tcTemp{
  1618  		{
  1619  			info: "vecf64 type to vecf32",
  1620  			inputs: []testutil.FunctionTestInput{
  1621  				testutil.NewFunctionTestInput(types.T_array_float64.ToType(), [][]float64{{1, 2, 3}, {4, 5, 6}}, nil),
  1622  				testutil.NewFunctionTestInput(types.T_array_float32.ToType(), [][]float32{}, []bool{}),
  1623  			},
  1624  			expect: testutil.NewFunctionTestResult(types.T_array_float32.ToType(), false, [][]float32{{1, 2, 3}, {4, 5, 6}}, []bool{false, false}),
  1625  		},
  1626  	}
  1627  
  1628  	castBitToOthers := []tcTemp{
  1629  		// test cast bit to others.
  1630  		{
  1631  			info: "bit to int8",
  1632  			inputs: []testutil.FunctionTestInput{
  1633  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{125, 256, 0}, []bool{false, false, true}),
  1634  				testutil.NewFunctionTestInput(types.T_int8.ToType(), []int8{}, []bool{}),
  1635  			},
  1636  			expect: testutil.NewFunctionTestResult(types.T_int8.ToType(), true, []int8{}, []bool{}),
  1637  		},
  1638  		{
  1639  			info: "bit to int16",
  1640  			inputs: []testutil.FunctionTestInput{
  1641  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{125, 126, 0}, []bool{false, false, true}),
  1642  				testutil.NewFunctionTestInput(types.T_int16.ToType(), []int16{}, []bool{}),
  1643  			},
  1644  			expect: testutil.NewFunctionTestResult(types.T_int16.ToType(), false,
  1645  				[]int16{125, 126, 0}, []bool{false, false, true}),
  1646  		},
  1647  		{
  1648  			info: "bit to int32",
  1649  			inputs: []testutil.FunctionTestInput{
  1650  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{125, 126, 0}, []bool{false, false, true}),
  1651  				testutil.NewFunctionTestInput(types.T_int32.ToType(), []int32{}, []bool{}),
  1652  			},
  1653  			expect: testutil.NewFunctionTestResult(types.T_int32.ToType(), false,
  1654  				[]int32{125, 126, 0}, []bool{false, false, true}),
  1655  		},
  1656  		{
  1657  			info: "bit to uint8",
  1658  			inputs: []testutil.FunctionTestInput{
  1659  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{125, 126, 0}, []bool{false, false, true}),
  1660  				testutil.NewFunctionTestInput(types.T_uint8.ToType(), []uint8{}, []bool{}),
  1661  			},
  1662  			expect: testutil.NewFunctionTestResult(types.T_uint8.ToType(), false,
  1663  				[]uint8{125, 126, 0}, []bool{false, false, true}),
  1664  		},
  1665  		{
  1666  			info: "bit to uint16",
  1667  			inputs: []testutil.FunctionTestInput{
  1668  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{125, 126, 0}, []bool{false, false, true}),
  1669  				testutil.NewFunctionTestInput(types.T_uint16.ToType(), []uint16{}, []bool{}),
  1670  			},
  1671  			expect: testutil.NewFunctionTestResult(types.T_uint16.ToType(), false,
  1672  				[]uint16{125, 126, 0}, []bool{false, false, true}),
  1673  		},
  1674  		{
  1675  			info: "bit to uint32",
  1676  			inputs: []testutil.FunctionTestInput{
  1677  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{125, 126, 0}, []bool{false, false, true}),
  1678  				testutil.NewFunctionTestInput(types.T_uint32.ToType(), []uint32{}, []bool{}),
  1679  			},
  1680  			expect: testutil.NewFunctionTestResult(types.T_uint32.ToType(), false,
  1681  				[]uint32{125, 126, 0}, []bool{false, false, true}),
  1682  		},
  1683  		{
  1684  			info: "bit to int64",
  1685  			inputs: []testutil.FunctionTestInput{
  1686  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{125, 126, 0}, []bool{false, false, true}),
  1687  				testutil.NewFunctionTestInput(types.T_int64.ToType(), []int64{}, []bool{}),
  1688  			},
  1689  			expect: testutil.NewFunctionTestResult(types.T_int64.ToType(), false,
  1690  				[]int64{125, 126, 0}, []bool{false, false, true}),
  1691  		},
  1692  		{
  1693  			info: "bit to float32",
  1694  			inputs: []testutil.FunctionTestInput{
  1695  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{125, 126, 0}, []bool{false, false, true}),
  1696  				testutil.NewFunctionTestInput(types.T_float32.ToType(), []float32{}, []bool{}),
  1697  			},
  1698  			expect: testutil.NewFunctionTestResult(types.T_float32.ToType(), false,
  1699  				[]float32{125, 126, 0}, []bool{false, false, true}),
  1700  		},
  1701  		{
  1702  			info: "bit to float64",
  1703  			inputs: []testutil.FunctionTestInput{
  1704  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{125, 126, 0}, []bool{false, false, true}),
  1705  				testutil.NewFunctionTestInput(types.T_float64.ToType(), []float64{}, []bool{}),
  1706  			},
  1707  			expect: testutil.NewFunctionTestResult(types.T_float64.ToType(), false,
  1708  				[]float64{125, 126, 0}, []bool{false, false, true}),
  1709  		},
  1710  		{
  1711  			info: "bit to decimal128",
  1712  			inputs: []testutil.FunctionTestInput{
  1713  				testutil.NewFunctionTestInput(types.T_bit.ToType(), []uint64{125, 0}, []bool{false, true}),
  1714  				testutil.NewFunctionTestInput(types.T_decimal128.ToType(), []types.Decimal128{}, []bool{}),
  1715  			},
  1716  			expect: testutil.NewFunctionTestResult(types.T_decimal128.ToType(), false,
  1717  				[]types.Decimal128{{B0_63: 125, B64_127: 0}, {B0_63: 0, B64_127: 0}},
  1718  				[]bool{false, true}),
  1719  		},
  1720  	}
  1721  
  1722  	// init the testCases
  1723  	testCases = append(testCases, castFloat64ToOthers...)
  1724  	testCases = append(testCases, castFloat32ToOthers...)
  1725  	testCases = append(testCases, castStrToOthers...)
  1726  	testCases = append(testCases, castDecToOthers...)
  1727  	testCases = append(testCases, castTimestampToOthers...)
  1728  	testCases = append(testCases, castArrayFloat32ToOthers...)
  1729  	testCases = append(testCases, castArrayFloat64ToOthers...)
  1730  	testCases = append(testCases, castBitToOthers...)
  1731  	testCases = append(testCases, castToSameTypeCases...)
  1732  	testCases = append(testCases, castInt8ToOthers...)
  1733  	testCases = append(testCases, castInt16ToOthers...)
  1734  	testCases = append(testCases, castInt32ToOthers...)
  1735  	testCases = append(testCases, castInt64ToOthers...)
  1736  	testCases = append(testCases, castUint8ToOthers...)
  1737  	testCases = append(testCases, castUint16ToOthers...)
  1738  	testCases = append(testCases, castUint32ToOthers...)
  1739  	testCases = append(testCases, castUint64ToOthers...)
  1740  
  1741  	return testCases
  1742  }
  1743  
  1744  func TestCast(t *testing.T) {
  1745  	testCases := initCastTestCase()
  1746  
  1747  	// do the test work.
  1748  	proc := testutil.NewProcess()
  1749  	for _, tc := range testCases {
  1750  		fcTC := testutil.NewFunctionTestCase(proc,
  1751  			tc.inputs, tc.expect, NewCast)
  1752  		s, info := fcTC.Run()
  1753  		require.True(t, s, fmt.Sprintf("case is '%s', err info is '%s'", tc.info, info))
  1754  	}
  1755  }
  1756  
  1757  func BenchmarkCast(b *testing.B) {
  1758  	testCases := initCastTestCase()
  1759  	proc := testutil.NewProcess()
  1760  
  1761  	b.StartTimer()
  1762  	for _, tc := range testCases {
  1763  		fcTC := testutil.NewFunctionTestCase(proc,
  1764  			tc.inputs, tc.expect, NewCast)
  1765  		_ = fcTC.BenchMarkRun()
  1766  	}
  1767  	b.StopTimer()
  1768  }