github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/plan/function/func_compare.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  	"bytes"
    19  
    20  	"github.com/matrixorigin/matrixone/pkg/common/moerr"
    21  	"github.com/matrixorigin/matrixone/pkg/container/nulls"
    22  	"github.com/matrixorigin/matrixone/pkg/container/types"
    23  	"github.com/matrixorigin/matrixone/pkg/container/vector"
    24  	"github.com/matrixorigin/matrixone/pkg/vectorize/moarray"
    25  	"github.com/matrixorigin/matrixone/pkg/vm/process"
    26  )
    27  
    28  func otherCompareOperatorSupports(typ1, typ2 types.Type) bool {
    29  	if typ1.Oid != typ2.Oid {
    30  		return false
    31  	}
    32  	switch typ1.Oid {
    33  	case types.T_bool:
    34  	case types.T_bit:
    35  	case types.T_uint8, types.T_uint16, types.T_uint32, types.T_uint64:
    36  	case types.T_int8, types.T_int16, types.T_int32, types.T_int64:
    37  	case types.T_float32, types.T_float64:
    38  	case types.T_decimal64, types.T_decimal128:
    39  	case types.T_char, types.T_varchar:
    40  	case types.T_date, types.T_datetime:
    41  	case types.T_timestamp, types.T_time:
    42  	case types.T_blob, types.T_text:
    43  	case types.T_binary, types.T_varbinary:
    44  	case types.T_uuid:
    45  	case types.T_Rowid:
    46  	case types.T_array_float32, types.T_array_float64:
    47  	default:
    48  		return false
    49  	}
    50  	return true
    51  }
    52  
    53  func equalAndNotEqualOperatorSupports(typ1, typ2 types.Type) bool {
    54  	if typ1.Oid != typ2.Oid {
    55  		return false
    56  	}
    57  	switch typ1.Oid {
    58  	case types.T_bool:
    59  	case types.T_bit:
    60  	case types.T_uint8, types.T_uint16, types.T_uint32, types.T_uint64:
    61  	case types.T_int8, types.T_int16, types.T_int32, types.T_int64:
    62  	case types.T_float32, types.T_float64:
    63  	case types.T_decimal64, types.T_decimal128:
    64  	case types.T_char, types.T_varchar:
    65  	case types.T_date, types.T_datetime:
    66  	case types.T_timestamp, types.T_time:
    67  	case types.T_blob, types.T_text:
    68  	case types.T_binary, types.T_varbinary:
    69  	case types.T_json:
    70  	case types.T_uuid:
    71  	case types.T_Rowid:
    72  	case types.T_array_float32, types.T_array_float64:
    73  	case types.T_enum:
    74  	default:
    75  		return false
    76  	}
    77  	return true
    78  }
    79  
    80  // should convert to c.Numeric next.
    81  func equalFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
    82  	paramType := parameters[0].GetType()
    83  	rs := vector.MustFunctionResult[bool](result)
    84  	switch paramType.Oid {
    85  	case types.T_bool:
    86  		return opBinaryFixedFixedToFixed[bool, bool, bool](parameters, rs, proc, length, func(a, b bool) bool {
    87  			return a == b
    88  		})
    89  	case types.T_bit:
    90  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
    91  			return a == b
    92  		})
    93  	case types.T_int8:
    94  		return opBinaryFixedFixedToFixed[int8, int8, bool](parameters, rs, proc, length, func(a, b int8) bool {
    95  			return a == b
    96  		})
    97  	case types.T_int16:
    98  		return opBinaryFixedFixedToFixed[int16, int16, bool](parameters, rs, proc, length, func(a, b int16) bool {
    99  			return a == b
   100  		})
   101  	case types.T_int32:
   102  		return opBinaryFixedFixedToFixed[int32, int32, bool](parameters, rs, proc, length, func(a, b int32) bool {
   103  			return a == b
   104  		})
   105  	case types.T_int64:
   106  		return opBinaryFixedFixedToFixed[int64, int64, bool](parameters, rs, proc, length, func(a, b int64) bool {
   107  			return a == b
   108  		})
   109  	case types.T_uint8:
   110  		return opBinaryFixedFixedToFixed[uint8, uint8, bool](parameters, rs, proc, length, func(a, b uint8) bool {
   111  			return a == b
   112  		})
   113  	case types.T_uint16:
   114  		return opBinaryFixedFixedToFixed[uint16, uint16, bool](parameters, rs, proc, length, func(a, b uint16) bool {
   115  			return a == b
   116  		})
   117  	case types.T_uint32:
   118  		return opBinaryFixedFixedToFixed[uint32, uint32, bool](parameters, rs, proc, length, func(a, b uint32) bool {
   119  			return a == b
   120  		})
   121  	case types.T_uint64:
   122  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
   123  			return a == b
   124  		})
   125  	case types.T_uuid:
   126  		return opBinaryFixedFixedToFixed[types.Uuid, types.Uuid, bool](parameters, rs, proc, length, func(a, b types.Uuid) bool {
   127  			return a == b
   128  		})
   129  	case types.T_float32:
   130  		return opBinaryFixedFixedToFixed[float32, float32, bool](parameters, rs, proc, length, func(a, b float32) bool {
   131  			return a == b
   132  		})
   133  	case types.T_float64:
   134  		return opBinaryFixedFixedToFixed[float64, float64, bool](parameters, rs, proc, length, func(a, b float64) bool {
   135  			return a == b
   136  		})
   137  	case types.T_char, types.T_varchar, types.T_blob, types.T_json, types.T_text, types.T_binary, types.T_varbinary:
   138  		if parameters[0].GetArea() == nil && parameters[1].GetArea() == nil {
   139  			return compareVarlenaEqual(parameters, rs, proc, length)
   140  		}
   141  		return opBinaryStrStrToFixed[bool](parameters, rs, proc, length, func(v1, v2 string) bool {
   142  			return v1 == v2
   143  		})
   144  	case types.T_array_float32:
   145  		if parameters[0].GetArea() == nil && parameters[1].GetArea() == nil {
   146  			return compareVarlenaEqual(parameters, rs, proc, length)
   147  		}
   148  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
   149  			_v1 := types.BytesToArray[float32](v1)
   150  			_v2 := types.BytesToArray[float32](v2)
   151  
   152  			return moarray.Compare[float32](_v1, _v2) == 0
   153  		})
   154  	case types.T_array_float64:
   155  		if parameters[0].GetArea() == nil && parameters[1].GetArea() == nil {
   156  			return compareVarlenaEqual(parameters, rs, proc, length)
   157  		}
   158  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
   159  			_v1 := types.BytesToArray[float64](v1)
   160  			_v2 := types.BytesToArray[float64](v2)
   161  
   162  			return moarray.Compare[float64](_v1, _v2) == 0
   163  		})
   164  	case types.T_date:
   165  		return opBinaryFixedFixedToFixed[types.Date, types.Date, bool](parameters, rs, proc, length, func(a, b types.Date) bool {
   166  			return a == b
   167  		})
   168  	case types.T_datetime:
   169  		return opBinaryFixedFixedToFixed[types.Datetime, types.Datetime, bool](parameters, rs, proc, length, func(a, b types.Datetime) bool {
   170  			return a == b
   171  		})
   172  	case types.T_time:
   173  		return opBinaryFixedFixedToFixed[types.Time, types.Time, bool](parameters, rs, proc, length, func(a, b types.Time) bool {
   174  			return a == b
   175  		})
   176  	case types.T_timestamp:
   177  		return opBinaryFixedFixedToFixed[types.Timestamp, types.Timestamp, bool](parameters, rs, proc, length, func(a, b types.Timestamp) bool {
   178  			return a == b
   179  		})
   180  	case types.T_decimal64:
   181  		return valueDec64Compare(parameters, rs, uint64(length), func(a, b types.Decimal64) bool {
   182  			return a == b
   183  		})
   184  	case types.T_decimal128:
   185  		return valueDec128Compare(parameters, rs, uint64(length), func(a, b types.Decimal128) bool {
   186  			return a == b
   187  		})
   188  	case types.T_Rowid:
   189  		return opBinaryFixedFixedToFixed[types.Rowid, types.Rowid, bool](parameters, rs, proc, length, func(a, b types.Rowid) bool {
   190  			return a.Equal(b)
   191  		})
   192  	case types.T_enum:
   193  		return opBinaryFixedFixedToFixed[types.Enum, types.Enum, bool](parameters, rs, proc, length, func(a, b types.Enum) bool {
   194  			return a == b
   195  		})
   196  	}
   197  	panic("unreached code")
   198  }
   199  
   200  func valueDec64Compare(
   201  	parameters []*vector.Vector, result *vector.FunctionResult[bool], length uint64,
   202  	cmpFn func(a, b types.Decimal64) bool) error {
   203  	p1 := vector.GenerateFunctionFixedTypeParameter[types.Decimal64](parameters[0])
   204  	p2 := vector.GenerateFunctionFixedTypeParameter[types.Decimal64](parameters[1])
   205  
   206  	m := p2.GetType().Scale - p1.GetType().Scale
   207  
   208  	rsVec := result.GetResultVector()
   209  	rss := vector.MustFixedCol[bool](rsVec)
   210  
   211  	c1, c2 := parameters[0].IsConst(), parameters[1].IsConst()
   212  
   213  	if c1 && c2 {
   214  		v1, null1 := p1.GetValue(0)
   215  		v2, null2 := p2.GetValue(0)
   216  		if null1 || null2 {
   217  			nulls.AddRange(rsVec.GetNulls(), 0, length)
   218  		} else {
   219  			if m >= 0 {
   220  				x, _ := v1.Scale(m)
   221  				for i := uint64(0); i < length; i++ {
   222  					rss[i] = cmpFn(x, v2)
   223  				}
   224  			} else {
   225  				y, _ := v2.Scale(-m)
   226  				for i := uint64(0); i < length; i++ {
   227  					rss[i] = cmpFn(v1, y)
   228  				}
   229  			}
   230  		}
   231  		return nil
   232  	}
   233  
   234  	if c1 {
   235  		v1, null1 := p1.GetValue(0)
   236  		if null1 {
   237  			nulls.AddRange(rsVec.GetNulls(), 0, length)
   238  		} else {
   239  			if m >= 0 {
   240  				x, _ := v1.Scale(m)
   241  				if p2.WithAnyNullValue() {
   242  					nulls.Or(rsVec.GetNulls(), parameters[1].GetNulls(), rsVec.GetNulls())
   243  					for i := uint64(0); i < length; i++ {
   244  						v2, null2 := p2.GetValue(i)
   245  						if null2 {
   246  							continue
   247  						}
   248  						rss[i] = cmpFn(x, v2)
   249  					}
   250  				} else {
   251  					for i := uint64(0); i < length; i++ {
   252  						v2, _ := p2.GetValue(i)
   253  						rss[i] = cmpFn(x, v2)
   254  					}
   255  				}
   256  			} else {
   257  				if p2.WithAnyNullValue() {
   258  					nulls.Or(rsVec.GetNulls(), parameters[1].GetNulls(), rsVec.GetNulls())
   259  					for i := uint64(0); i < length; i++ {
   260  						v2, null2 := p2.GetValue(i)
   261  						if null2 {
   262  							continue
   263  						}
   264  						y, _ := v2.Scale(-m)
   265  						rss[i] = cmpFn(v1, y)
   266  					}
   267  				} else {
   268  					scaleMy := -m
   269  					for i := uint64(0); i < length; i++ {
   270  						v2, _ := p2.GetValue(i)
   271  						y, _ := v2.Scale(scaleMy)
   272  						rss[i] = cmpFn(v1, y)
   273  					}
   274  				}
   275  			}
   276  		}
   277  
   278  		return nil
   279  	}
   280  
   281  	if c2 {
   282  		v2, null2 := p2.GetValue(0)
   283  		if null2 {
   284  			nulls.AddRange(rsVec.GetNulls(), 0, length)
   285  		} else {
   286  			if m >= 0 {
   287  				if p1.WithAnyNullValue() {
   288  					nulls.Or(rsVec.GetNulls(), parameters[0].GetNulls(), rsVec.GetNulls())
   289  					for i := uint64(0); i < length; i++ {
   290  						v1, null1 := p1.GetValue(i)
   291  						if null1 {
   292  							continue
   293  						}
   294  						x, _ := v1.Scale(m)
   295  						rss[i] = cmpFn(x, v2)
   296  					}
   297  				} else {
   298  					for i := uint64(0); i < length; i++ {
   299  						v1, _ := p1.GetValue(i)
   300  						x, _ := v1.Scale(m)
   301  						rss[i] = cmpFn(x, v2)
   302  					}
   303  				}
   304  			} else {
   305  				y, _ := v2.Scale(-m)
   306  				if p1.WithAnyNullValue() {
   307  					nulls.Or(rsVec.GetNulls(), parameters[0].GetNulls(), rsVec.GetNulls())
   308  					for i := uint64(0); i < length; i++ {
   309  						v1, null1 := p1.GetValue(i)
   310  						if null1 {
   311  							continue
   312  						}
   313  						rss[i] = cmpFn(v1, y)
   314  					}
   315  				} else {
   316  					for i := uint64(0); i < length; i++ {
   317  						v1, _ := p1.GetValue(i)
   318  						rss[i] = cmpFn(v1, y)
   319  					}
   320  				}
   321  			}
   322  		}
   323  		return nil
   324  	}
   325  
   326  	if p1.WithAnyNullValue() || p2.WithAnyNullValue() {
   327  		nulls.Or(parameters[0].GetNulls(), parameters[1].GetNulls(), rsVec.GetNulls())
   328  
   329  		resultNsp := rsVec.GetNulls()
   330  		if m >= 0 {
   331  			for i := uint64(0); i < length; i++ {
   332  				if resultNsp.Contains(i) {
   333  					continue
   334  				}
   335  				v1, _ := p1.GetValue(i)
   336  				v2, _ := p2.GetValue(i)
   337  				x, _ := v1.Scale(m)
   338  				rss[i] = cmpFn(x, v2)
   339  			}
   340  		} else {
   341  			scaleMy := -m
   342  			for i := uint64(0); i < length; i++ {
   343  				if resultNsp.Contains(i) {
   344  					continue
   345  				}
   346  				v1, _ := p1.GetValue(i)
   347  				v2, _ := p2.GetValue(i)
   348  				y, _ := v2.Scale(scaleMy)
   349  				rss[i] = cmpFn(v1, y)
   350  			}
   351  		}
   352  		return nil
   353  	}
   354  
   355  	if m >= 0 {
   356  		for i := uint64(0); i < length; i++ {
   357  			v1, _ := p1.GetValue(i)
   358  			v2, _ := p2.GetValue(i)
   359  			x, _ := v1.Scale(m)
   360  			rss[i] = cmpFn(x, v2)
   361  		}
   362  	} else {
   363  		scaleMy := -m
   364  		for i := uint64(0); i < length; i++ {
   365  			v1, _ := p1.GetValue(i)
   366  			v2, _ := p2.GetValue(i)
   367  			y, _ := v2.Scale(scaleMy)
   368  			rss[i] = cmpFn(v1, y)
   369  		}
   370  	}
   371  	return nil
   372  }
   373  
   374  func valueDec128Compare(
   375  	parameters []*vector.Vector, result *vector.FunctionResult[bool], length uint64,
   376  	cmpFn func(a, b types.Decimal128) bool) error {
   377  	p1 := vector.GenerateFunctionFixedTypeParameter[types.Decimal128](parameters[0])
   378  	p2 := vector.GenerateFunctionFixedTypeParameter[types.Decimal128](parameters[1])
   379  
   380  	m := p2.GetType().Scale - p1.GetType().Scale
   381  
   382  	rsVec := result.GetResultVector()
   383  	rss := vector.MustFixedCol[bool](rsVec)
   384  
   385  	c1, c2 := parameters[0].IsConst(), parameters[1].IsConst()
   386  
   387  	if c1 && c2 {
   388  		v1, null1 := p1.GetValue(0)
   389  		v2, null2 := p2.GetValue(0)
   390  		if null1 || null2 {
   391  			nulls.AddRange(rsVec.GetNulls(), 0, length)
   392  		} else {
   393  			if m >= 0 {
   394  				x, _ := v1.Scale(m)
   395  				for i := uint64(0); i < length; i++ {
   396  					rss[i] = cmpFn(x, v2)
   397  				}
   398  			} else {
   399  				y, _ := v2.Scale(-m)
   400  				for i := uint64(0); i < length; i++ {
   401  					rss[i] = cmpFn(v1, y)
   402  				}
   403  			}
   404  		}
   405  		return nil
   406  	}
   407  
   408  	if c1 {
   409  		v1, null1 := p1.GetValue(0)
   410  		if null1 {
   411  			nulls.AddRange(rsVec.GetNulls(), 0, length)
   412  		} else {
   413  			if m >= 0 {
   414  				x, _ := v1.Scale(m)
   415  				if p2.WithAnyNullValue() {
   416  					nulls.Or(rsVec.GetNulls(), parameters[1].GetNulls(), rsVec.GetNulls())
   417  					for i := uint64(0); i < length; i++ {
   418  						v2, null2 := p2.GetValue(i)
   419  						if null2 {
   420  							continue
   421  						}
   422  						rss[i] = cmpFn(x, v2)
   423  					}
   424  				} else {
   425  					for i := uint64(0); i < length; i++ {
   426  						v2, _ := p2.GetValue(i)
   427  						rss[i] = cmpFn(x, v2)
   428  					}
   429  				}
   430  			} else {
   431  				if p2.WithAnyNullValue() {
   432  					nulls.Or(rsVec.GetNulls(), parameters[1].GetNulls(), rsVec.GetNulls())
   433  					for i := uint64(0); i < length; i++ {
   434  						v2, null2 := p2.GetValue(i)
   435  						if null2 {
   436  							continue
   437  						}
   438  						y, _ := v2.Scale(-m)
   439  						rss[i] = cmpFn(v1, y)
   440  					}
   441  				} else {
   442  					scaleMy := -m
   443  					for i := uint64(0); i < length; i++ {
   444  						v2, _ := p2.GetValue(i)
   445  						y, _ := v2.Scale(scaleMy)
   446  						rss[i] = cmpFn(v1, y)
   447  					}
   448  				}
   449  			}
   450  		}
   451  
   452  		return nil
   453  	}
   454  
   455  	if c2 {
   456  		v2, null2 := p2.GetValue(0)
   457  		if null2 {
   458  			nulls.AddRange(rsVec.GetNulls(), 0, length)
   459  		} else {
   460  			if m >= 0 {
   461  				if p1.WithAnyNullValue() {
   462  					nulls.Or(rsVec.GetNulls(), parameters[0].GetNulls(), rsVec.GetNulls())
   463  					for i := uint64(0); i < length; i++ {
   464  						v1, null1 := p1.GetValue(i)
   465  						if null1 {
   466  							continue
   467  						}
   468  						x, _ := v1.Scale(m)
   469  						rss[i] = cmpFn(x, v2)
   470  					}
   471  				} else {
   472  					for i := uint64(0); i < length; i++ {
   473  						v1, _ := p1.GetValue(i)
   474  						x, _ := v1.Scale(m)
   475  						rss[i] = cmpFn(x, v2)
   476  					}
   477  				}
   478  			} else {
   479  				y, _ := v2.Scale(-m)
   480  				if p1.WithAnyNullValue() {
   481  					nulls.Or(rsVec.GetNulls(), parameters[0].GetNulls(), rsVec.GetNulls())
   482  					for i := uint64(0); i < length; i++ {
   483  						v1, null1 := p1.GetValue(i)
   484  						if null1 {
   485  							continue
   486  						}
   487  						rss[i] = cmpFn(v1, y)
   488  					}
   489  				} else {
   490  					for i := uint64(0); i < length; i++ {
   491  						v1, _ := p1.GetValue(i)
   492  						rss[i] = cmpFn(v1, y)
   493  					}
   494  				}
   495  			}
   496  		}
   497  		return nil
   498  	}
   499  
   500  	if p1.WithAnyNullValue() || p2.WithAnyNullValue() {
   501  		nulls.Or(parameters[0].GetNulls(), parameters[1].GetNulls(), rsVec.GetNulls())
   502  
   503  		resultNsp := rsVec.GetNulls()
   504  		if m >= 0 {
   505  			for i := uint64(0); i < length; i++ {
   506  				if resultNsp.Contains(i) {
   507  					continue
   508  				}
   509  				v1, _ := p1.GetValue(i)
   510  				v2, _ := p2.GetValue(i)
   511  				x, _ := v1.Scale(m)
   512  				rss[i] = cmpFn(x, v2)
   513  			}
   514  		} else {
   515  			scaleMy := -m
   516  			for i := uint64(0); i < length; i++ {
   517  				if resultNsp.Contains(i) {
   518  					continue
   519  				}
   520  				v1, _ := p1.GetValue(i)
   521  				v2, _ := p2.GetValue(i)
   522  				y, _ := v2.Scale(scaleMy)
   523  				rss[i] = cmpFn(v1, y)
   524  			}
   525  		}
   526  		return nil
   527  	}
   528  
   529  	if m >= 0 {
   530  		for i := uint64(0); i < length; i++ {
   531  			v1, _ := p1.GetValue(i)
   532  			v2, _ := p2.GetValue(i)
   533  			x, _ := v1.Scale(m)
   534  			rss[i] = cmpFn(x, v2)
   535  		}
   536  	} else {
   537  		scaleMy := -m
   538  		for i := uint64(0); i < length; i++ {
   539  			v1, _ := p1.GetValue(i)
   540  			v2, _ := p2.GetValue(i)
   541  			y, _ := v2.Scale(scaleMy)
   542  			rss[i] = cmpFn(v1, y)
   543  		}
   544  	}
   545  	return nil
   546  }
   547  
   548  func greatThanFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
   549  	paramType := parameters[0].GetType()
   550  	rs := vector.MustFunctionResult[bool](result)
   551  	switch paramType.Oid {
   552  	case types.T_bit:
   553  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
   554  			return a > b
   555  		})
   556  	case types.T_bool:
   557  		return opBinaryFixedFixedToFixed[bool, bool, bool](parameters, rs, proc, length, func(x, y bool) bool {
   558  			return x && !y
   559  		})
   560  	case types.T_int8:
   561  		return opBinaryFixedFixedToFixed[int8, int8, bool](parameters, rs, proc, length, func(a, b int8) bool {
   562  			return a > b
   563  		})
   564  	case types.T_int16:
   565  		return opBinaryFixedFixedToFixed[int16, int16, bool](parameters, rs, proc, length, func(a, b int16) bool {
   566  			return a > b
   567  		})
   568  	case types.T_int32:
   569  		return opBinaryFixedFixedToFixed[int32, int32, bool](parameters, rs, proc, length, func(a, b int32) bool {
   570  			return a > b
   571  		})
   572  	case types.T_int64:
   573  		return opBinaryFixedFixedToFixed[int64, int64, bool](parameters, rs, proc, length, func(a, b int64) bool {
   574  			return a > b
   575  		})
   576  	case types.T_uint8:
   577  		return opBinaryFixedFixedToFixed[uint8, uint8, bool](parameters, rs, proc, length, func(a, b uint8) bool {
   578  			return a > b
   579  		})
   580  	case types.T_uint16:
   581  		return opBinaryFixedFixedToFixed[uint16, uint16, bool](parameters, rs, proc, length, func(a, b uint16) bool {
   582  			return a > b
   583  		})
   584  	case types.T_uint32:
   585  		return opBinaryFixedFixedToFixed[uint32, uint32, bool](parameters, rs, proc, length, func(a, b uint32) bool {
   586  			return a > b
   587  		})
   588  	case types.T_uint64:
   589  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
   590  			return a > b
   591  		})
   592  	case types.T_uuid:
   593  		return opBinaryFixedFixedToFixed[types.Uuid, types.Uuid, bool](parameters, rs, proc, length, func(v1, v2 types.Uuid) bool {
   594  			return types.CompareUuid(v1, v2) > 0
   595  		})
   596  	case types.T_float32:
   597  		return opBinaryFixedFixedToFixed[float32, float32, bool](parameters, rs, proc, length, func(a, b float32) bool {
   598  			return a > b
   599  		})
   600  	case types.T_float64:
   601  		return opBinaryFixedFixedToFixed[float64, float64, bool](parameters, rs, proc, length, func(a, b float64) bool {
   602  			return a > b
   603  		})
   604  	case types.T_char, types.T_varchar, types.T_blob, types.T_text:
   605  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(a, b []byte) bool {
   606  			return bytes.Compare(a, b) > 0
   607  		})
   608  	case types.T_binary, types.T_varbinary:
   609  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(a, b []byte) bool {
   610  			return bytes.Compare(a, b) > 0
   611  		})
   612  	case types.T_array_float32:
   613  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
   614  			_v1 := types.BytesToArray[float32](v1)
   615  			_v2 := types.BytesToArray[float32](v2)
   616  
   617  			return moarray.Compare[float32](_v1, _v2) > 0
   618  		})
   619  	case types.T_array_float64:
   620  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
   621  			_v1 := types.BytesToArray[float64](v1)
   622  			_v2 := types.BytesToArray[float64](v2)
   623  
   624  			return moarray.Compare[float64](_v1, _v2) > 0
   625  		})
   626  	case types.T_date:
   627  		return opBinaryFixedFixedToFixed[types.Date, types.Date, bool](parameters, rs, proc, length, func(a, b types.Date) bool {
   628  			return a > b
   629  		})
   630  	case types.T_datetime:
   631  		return opBinaryFixedFixedToFixed[types.Datetime, types.Datetime, bool](parameters, rs, proc, length, func(a, b types.Datetime) bool {
   632  			return a > b
   633  		})
   634  	case types.T_time:
   635  		return opBinaryFixedFixedToFixed[types.Time, types.Time, bool](parameters, rs, proc, length, func(a, b types.Time) bool {
   636  			return a > b
   637  		})
   638  	case types.T_timestamp:
   639  		return opBinaryFixedFixedToFixed[types.Timestamp, types.Timestamp, bool](parameters, rs, proc, length, func(a, b types.Timestamp) bool {
   640  			return a > b
   641  		})
   642  	case types.T_decimal64:
   643  		return valueDec64Compare(parameters, rs, uint64(length), func(a, b types.Decimal64) bool {
   644  			return a.Compare(b) > 0
   645  		})
   646  	case types.T_decimal128:
   647  		return valueDec128Compare(parameters, rs, uint64(length), func(a, b types.Decimal128) bool {
   648  			return a.Compare(b) > 0
   649  		})
   650  	case types.T_Rowid:
   651  		return opBinaryFixedFixedToFixed[types.Rowid, types.Rowid, bool](parameters, rs, proc, length, func(a, b types.Rowid) bool {
   652  			return a.Great(b)
   653  		})
   654  	}
   655  	panic("unreached code")
   656  }
   657  
   658  func greatEqualFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
   659  	paramType := parameters[0].GetType()
   660  	rs := vector.MustFunctionResult[bool](result)
   661  	switch paramType.Oid {
   662  	case types.T_bool:
   663  		return opBinaryFixedFixedToFixed[bool, bool, bool](parameters, rs, proc, length, func(x, y bool) bool {
   664  			return x || !y
   665  		})
   666  	case types.T_bit:
   667  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
   668  			return a >= b
   669  		})
   670  	case types.T_int8:
   671  		return opBinaryFixedFixedToFixed[int8, int8, bool](parameters, rs, proc, length, func(a, b int8) bool {
   672  			return a >= b
   673  		})
   674  	case types.T_int16:
   675  		return opBinaryFixedFixedToFixed[int16, int16, bool](parameters, rs, proc, length, func(a, b int16) bool {
   676  			return a >= b
   677  		})
   678  	case types.T_int32:
   679  		return opBinaryFixedFixedToFixed[int32, int32, bool](parameters, rs, proc, length, func(a, b int32) bool {
   680  			return a >= b
   681  		})
   682  	case types.T_int64:
   683  		return opBinaryFixedFixedToFixed[int64, int64, bool](parameters, rs, proc, length, func(a, b int64) bool {
   684  			return a >= b
   685  		})
   686  	case types.T_uint8:
   687  		return opBinaryFixedFixedToFixed[uint8, uint8, bool](parameters, rs, proc, length, func(a, b uint8) bool {
   688  			return a >= b
   689  		})
   690  	case types.T_uint16:
   691  		return opBinaryFixedFixedToFixed[uint16, uint16, bool](parameters, rs, proc, length, func(a, b uint16) bool {
   692  			return a >= b
   693  		})
   694  	case types.T_uint32:
   695  		return opBinaryFixedFixedToFixed[uint32, uint32, bool](parameters, rs, proc, length, func(a, b uint32) bool {
   696  			return a >= b
   697  		})
   698  	case types.T_uint64:
   699  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
   700  			return a >= b
   701  		})
   702  	case types.T_uuid:
   703  		return opBinaryFixedFixedToFixed[types.Uuid, types.Uuid, bool](parameters, rs, proc, length, func(v1, v2 types.Uuid) bool {
   704  			return types.CompareUuid(v1, v2) >= 0
   705  		})
   706  	case types.T_float32:
   707  		return opBinaryFixedFixedToFixed[float32, float32, bool](parameters, rs, proc, length, func(a, b float32) bool {
   708  			return a >= b
   709  		})
   710  	case types.T_float64:
   711  		return opBinaryFixedFixedToFixed[float64, float64, bool](parameters, rs, proc, length, func(a, b float64) bool {
   712  			return a >= b
   713  		})
   714  	case types.T_char, types.T_varchar, types.T_blob, types.T_text:
   715  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(a, b []byte) bool {
   716  			return bytes.Compare(a, b) >= 0
   717  		})
   718  	case types.T_binary, types.T_varbinary:
   719  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(a, b []byte) bool {
   720  			return bytes.Compare(a, b) >= 0
   721  		})
   722  	case types.T_array_float32:
   723  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
   724  			_v1 := types.BytesToArray[float32](v1)
   725  			_v2 := types.BytesToArray[float32](v2)
   726  
   727  			return moarray.Compare[float32](_v1, _v2) >= 0
   728  		})
   729  	case types.T_array_float64:
   730  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
   731  			_v1 := types.BytesToArray[float64](v1)
   732  			_v2 := types.BytesToArray[float64](v2)
   733  
   734  			return moarray.Compare[float64](_v1, _v2) >= 0
   735  		})
   736  	case types.T_date:
   737  		return opBinaryFixedFixedToFixed[types.Date, types.Date, bool](parameters, rs, proc, length, func(a, b types.Date) bool {
   738  			return a >= b
   739  		})
   740  	case types.T_datetime:
   741  		return opBinaryFixedFixedToFixed[types.Datetime, types.Datetime, bool](parameters, rs, proc, length, func(a, b types.Datetime) bool {
   742  			return a >= b
   743  		})
   744  	case types.T_time:
   745  		return opBinaryFixedFixedToFixed[types.Time, types.Time, bool](parameters, rs, proc, length, func(a, b types.Time) bool {
   746  			return a >= b
   747  		})
   748  	case types.T_timestamp:
   749  		return opBinaryFixedFixedToFixed[types.Timestamp, types.Timestamp, bool](parameters, rs, proc, length, func(a, b types.Timestamp) bool {
   750  			return a >= b
   751  		})
   752  	case types.T_decimal64:
   753  		return valueDec64Compare(parameters, rs, uint64(length), func(a, b types.Decimal64) bool {
   754  			return a.Compare(b) >= 0
   755  		})
   756  	case types.T_decimal128:
   757  		return valueDec128Compare(parameters, rs, uint64(length), func(a, b types.Decimal128) bool {
   758  			return a.Compare(b) >= 0
   759  		})
   760  	case types.T_Rowid:
   761  		return opBinaryFixedFixedToFixed[types.Rowid, types.Rowid, bool](parameters, rs, proc, length, func(a, b types.Rowid) bool {
   762  			return a.Ge(b)
   763  		})
   764  	}
   765  	panic("unreached code")
   766  }
   767  
   768  func notEqualFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
   769  	paramType := parameters[0].GetType()
   770  	rs := vector.MustFunctionResult[bool](result)
   771  	switch paramType.Oid {
   772  	case types.T_bool:
   773  		return opBinaryFixedFixedToFixed[bool, bool, bool](parameters, rs, proc, length, func(a, b bool) bool {
   774  			return a != b
   775  		})
   776  	case types.T_bit:
   777  		return opBinaryStrStrToFixed[bool](parameters, rs, proc, length, func(a, b string) bool {
   778  			return a != b
   779  		})
   780  	case types.T_int8:
   781  		return opBinaryFixedFixedToFixed[int8, int8, bool](parameters, rs, proc, length, func(a, b int8) bool {
   782  			return a != b
   783  		})
   784  	case types.T_int16:
   785  		return opBinaryFixedFixedToFixed[int16, int16, bool](parameters, rs, proc, length, func(a, b int16) bool {
   786  			return a != b
   787  		})
   788  	case types.T_int32:
   789  		return opBinaryFixedFixedToFixed[int32, int32, bool](parameters, rs, proc, length, func(a, b int32) bool {
   790  			return a != b
   791  		})
   792  	case types.T_int64:
   793  		return opBinaryFixedFixedToFixed[int64, int64, bool](parameters, rs, proc, length, func(a, b int64) bool {
   794  			return a != b
   795  		})
   796  	case types.T_uint8:
   797  		return opBinaryFixedFixedToFixed[uint8, uint8, bool](parameters, rs, proc, length, func(a, b uint8) bool {
   798  			return a != b
   799  		})
   800  	case types.T_uint16:
   801  		return opBinaryFixedFixedToFixed[uint16, uint16, bool](parameters, rs, proc, length, func(a, b uint16) bool {
   802  			return a != b
   803  		})
   804  	case types.T_uint32:
   805  		return opBinaryFixedFixedToFixed[uint32, uint32, bool](parameters, rs, proc, length, func(a, b uint32) bool {
   806  			return a != b
   807  		})
   808  	case types.T_uint64:
   809  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
   810  			return a != b
   811  		})
   812  	case types.T_uuid:
   813  		return opBinaryFixedFixedToFixed[types.Uuid, types.Uuid, bool](parameters, rs, proc, length, func(a, b types.Uuid) bool {
   814  			return a != b
   815  		})
   816  	case types.T_float32:
   817  		return opBinaryFixedFixedToFixed[float32, float32, bool](parameters, rs, proc, length, func(a, b float32) bool {
   818  			return a != b
   819  		})
   820  	case types.T_float64:
   821  		return opBinaryFixedFixedToFixed[float64, float64, bool](parameters, rs, proc, length, func(a, b float64) bool {
   822  			return a != b
   823  		})
   824  	case types.T_char, types.T_varchar, types.T_blob, types.T_json, types.T_text:
   825  		return opBinaryStrStrToFixed[bool](parameters, rs, proc, length, func(a, b string) bool {
   826  			return a != b
   827  		})
   828  	case types.T_binary, types.T_varbinary:
   829  		return opBinaryStrStrToFixed[bool](parameters, rs, proc, length, func(a, b string) bool {
   830  			return a != b
   831  		})
   832  	case types.T_array_float32:
   833  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
   834  			_v1 := types.BytesToArray[float32](v1)
   835  			_v2 := types.BytesToArray[float32](v2)
   836  
   837  			return moarray.Compare[float32](_v1, _v2) != 0
   838  		})
   839  	case types.T_array_float64:
   840  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
   841  			_v1 := types.BytesToArray[float64](v1)
   842  			_v2 := types.BytesToArray[float64](v2)
   843  
   844  			return moarray.Compare[float64](_v1, _v2) != 0
   845  		})
   846  	case types.T_date:
   847  		return opBinaryFixedFixedToFixed[types.Date, types.Date, bool](parameters, rs, proc, length, func(a, b types.Date) bool {
   848  			return a != b
   849  		})
   850  	case types.T_datetime:
   851  		return opBinaryFixedFixedToFixed[types.Datetime, types.Datetime, bool](parameters, rs, proc, length, func(a, b types.Datetime) bool {
   852  			return a != b
   853  		})
   854  	case types.T_time:
   855  		return opBinaryFixedFixedToFixed[types.Time, types.Time, bool](parameters, rs, proc, length, func(a, b types.Time) bool {
   856  			return a != b
   857  		})
   858  	case types.T_timestamp:
   859  		return opBinaryFixedFixedToFixed[types.Timestamp, types.Timestamp, bool](parameters, rs, proc, length, func(a, b types.Timestamp) bool {
   860  			return a != b
   861  		})
   862  	case types.T_decimal64:
   863  		return valueDec64Compare(parameters, rs, uint64(length), func(a, b types.Decimal64) bool {
   864  			return a != b
   865  		})
   866  	case types.T_decimal128:
   867  		return valueDec128Compare(parameters, rs, uint64(length), func(a, b types.Decimal128) bool {
   868  			return a != b
   869  		})
   870  	case types.T_Rowid:
   871  		return opBinaryFixedFixedToFixed[types.Rowid, types.Rowid, bool](parameters, rs, proc, length, func(a, b types.Rowid) bool {
   872  			return a.NotEqual(b)
   873  		})
   874  	}
   875  	panic("unreached code")
   876  }
   877  
   878  func lessThanFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
   879  	paramType := parameters[0].GetType()
   880  	rs := vector.MustFunctionResult[bool](result)
   881  	switch paramType.Oid {
   882  	case types.T_bool:
   883  		return opBinaryFixedFixedToFixed[bool, bool, bool](parameters, rs, proc, length, func(x, y bool) bool {
   884  			return !x && y
   885  		})
   886  	case types.T_bit:
   887  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
   888  			return a < b
   889  		})
   890  	case types.T_int8:
   891  		return opBinaryFixedFixedToFixed[int8, int8, bool](parameters, rs, proc, length, func(a, b int8) bool {
   892  			return a < b
   893  		})
   894  	case types.T_int16:
   895  		return opBinaryFixedFixedToFixed[int16, int16, bool](parameters, rs, proc, length, func(a, b int16) bool {
   896  			return a < b
   897  		})
   898  	case types.T_int32:
   899  		return opBinaryFixedFixedToFixed[int32, int32, bool](parameters, rs, proc, length, func(a, b int32) bool {
   900  			return a < b
   901  		})
   902  	case types.T_int64:
   903  		return opBinaryFixedFixedToFixed[int64, int64, bool](parameters, rs, proc, length, func(a, b int64) bool {
   904  			return a < b
   905  		})
   906  	case types.T_uint8:
   907  		return opBinaryFixedFixedToFixed[uint8, uint8, bool](parameters, rs, proc, length, func(a, b uint8) bool {
   908  			return a < b
   909  		})
   910  	case types.T_uint16:
   911  		return opBinaryFixedFixedToFixed[uint16, uint16, bool](parameters, rs, proc, length, func(a, b uint16) bool {
   912  			return a < b
   913  		})
   914  	case types.T_uint32:
   915  		return opBinaryFixedFixedToFixed[uint32, uint32, bool](parameters, rs, proc, length, func(a, b uint32) bool {
   916  			return a < b
   917  		})
   918  	case types.T_uint64:
   919  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
   920  			return a < b
   921  		})
   922  	case types.T_uuid:
   923  		return opBinaryFixedFixedToFixed[types.Uuid, types.Uuid, bool](parameters, rs, proc, length, func(v1, v2 types.Uuid) bool {
   924  			return types.CompareUuid(v1, v2) < 0
   925  		})
   926  	case types.T_float32:
   927  		return opBinaryFixedFixedToFixed[float32, float32, bool](parameters, rs, proc, length, func(a, b float32) bool {
   928  			return a < b
   929  		})
   930  	case types.T_float64:
   931  		return opBinaryFixedFixedToFixed[float64, float64, bool](parameters, rs, proc, length, func(a, b float64) bool {
   932  			return a < b
   933  		})
   934  	case types.T_char, types.T_varchar, types.T_blob, types.T_text:
   935  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(a, b []byte) bool {
   936  			return bytes.Compare(a, b) < 0
   937  		})
   938  	case types.T_binary, types.T_varbinary:
   939  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(a, b []byte) bool {
   940  			return bytes.Compare(a, b) < 0
   941  		})
   942  	case types.T_array_float32:
   943  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
   944  			_v1 := types.BytesToArray[float32](v1)
   945  			_v2 := types.BytesToArray[float32](v2)
   946  
   947  			return moarray.Compare[float32](_v1, _v2) < 0
   948  		})
   949  	case types.T_array_float64:
   950  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
   951  			_v1 := types.BytesToArray[float64](v1)
   952  			_v2 := types.BytesToArray[float64](v2)
   953  
   954  			return moarray.Compare[float64](_v1, _v2) < 0
   955  		})
   956  	case types.T_date:
   957  		return opBinaryFixedFixedToFixed[types.Date, types.Date, bool](parameters, rs, proc, length, func(a, b types.Date) bool {
   958  			return a < b
   959  		})
   960  	case types.T_datetime:
   961  		return opBinaryFixedFixedToFixed[types.Datetime, types.Datetime, bool](parameters, rs, proc, length, func(a, b types.Datetime) bool {
   962  			return a < b
   963  		})
   964  	case types.T_time:
   965  		return opBinaryFixedFixedToFixed[types.Time, types.Time, bool](parameters, rs, proc, length, func(a, b types.Time) bool {
   966  			return a < b
   967  		})
   968  	case types.T_timestamp:
   969  		return opBinaryFixedFixedToFixed[types.Timestamp, types.Timestamp, bool](parameters, rs, proc, length, func(a, b types.Timestamp) bool {
   970  			return a < b
   971  		})
   972  	case types.T_decimal64:
   973  		return valueDec64Compare(parameters, rs, uint64(length), func(a, b types.Decimal64) bool {
   974  			return a.Compare(b) < 0
   975  		})
   976  	case types.T_decimal128:
   977  		return valueDec128Compare(parameters, rs, uint64(length), func(a, b types.Decimal128) bool {
   978  			return a.Compare(b) < 0
   979  		})
   980  	case types.T_Rowid:
   981  		return opBinaryFixedFixedToFixed[types.Rowid, types.Rowid, bool](parameters, rs, proc, length, func(a, b types.Rowid) bool {
   982  			return a.Less(b)
   983  		})
   984  	}
   985  	panic("unreached code")
   986  }
   987  
   988  func lessEqualFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
   989  	paramType := parameters[0].GetType()
   990  	rs := vector.MustFunctionResult[bool](result)
   991  	switch paramType.Oid {
   992  	case types.T_bool:
   993  		return opBinaryFixedFixedToFixed[bool, bool, bool](parameters, rs, proc, length, func(x, y bool) bool {
   994  			return !x || y
   995  		})
   996  	case types.T_bit:
   997  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
   998  			return a <= b
   999  		})
  1000  	case types.T_int8:
  1001  		return opBinaryFixedFixedToFixed[int8, int8, bool](parameters, rs, proc, length, func(a, b int8) bool {
  1002  			return a <= b
  1003  		})
  1004  	case types.T_int16:
  1005  		return opBinaryFixedFixedToFixed[int16, int16, bool](parameters, rs, proc, length, func(a, b int16) bool {
  1006  			return a <= b
  1007  		})
  1008  	case types.T_int32:
  1009  		return opBinaryFixedFixedToFixed[int32, int32, bool](parameters, rs, proc, length, func(a, b int32) bool {
  1010  			return a <= b
  1011  		})
  1012  	case types.T_int64:
  1013  		return opBinaryFixedFixedToFixed[int64, int64, bool](parameters, rs, proc, length, func(a, b int64) bool {
  1014  			return a <= b
  1015  		})
  1016  	case types.T_uint8:
  1017  		return opBinaryFixedFixedToFixed[uint8, uint8, bool](parameters, rs, proc, length, func(a, b uint8) bool {
  1018  			return a <= b
  1019  		})
  1020  	case types.T_uint16:
  1021  		return opBinaryFixedFixedToFixed[uint16, uint16, bool](parameters, rs, proc, length, func(a, b uint16) bool {
  1022  			return a <= b
  1023  		})
  1024  	case types.T_uint32:
  1025  		return opBinaryFixedFixedToFixed[uint32, uint32, bool](parameters, rs, proc, length, func(a, b uint32) bool {
  1026  			return a <= b
  1027  		})
  1028  	case types.T_uint64:
  1029  		return opBinaryFixedFixedToFixed[uint64, uint64, bool](parameters, rs, proc, length, func(a, b uint64) bool {
  1030  			return a <= b
  1031  		})
  1032  	case types.T_uuid:
  1033  		return opBinaryFixedFixedToFixed[types.Uuid, types.Uuid, bool](parameters, rs, proc, length, func(v1, v2 types.Uuid) bool {
  1034  			return types.CompareUuid(v1, v2) <= 0
  1035  		})
  1036  	case types.T_float32:
  1037  		return opBinaryFixedFixedToFixed[float32, float32, bool](parameters, rs, proc, length, func(a, b float32) bool {
  1038  			return a <= b
  1039  		})
  1040  	case types.T_float64:
  1041  		return opBinaryFixedFixedToFixed[float64, float64, bool](parameters, rs, proc, length, func(a, b float64) bool {
  1042  			return a <= b
  1043  		})
  1044  	case types.T_char, types.T_varchar, types.T_blob, types.T_text:
  1045  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(a, b []byte) bool {
  1046  			return bytes.Compare(a, b) <= 0
  1047  		})
  1048  	case types.T_binary, types.T_varbinary:
  1049  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(a, b []byte) bool {
  1050  			return bytes.Compare(a, b) <= 0
  1051  		})
  1052  	case types.T_array_float32:
  1053  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
  1054  			_v1 := types.BytesToArray[float32](v1)
  1055  			_v2 := types.BytesToArray[float32](v2)
  1056  
  1057  			return moarray.Compare[float32](_v1, _v2) <= 0
  1058  		})
  1059  	case types.T_array_float64:
  1060  		return opBinaryBytesBytesToFixed[bool](parameters, rs, proc, length, func(v1, v2 []byte) bool {
  1061  			_v1 := types.BytesToArray[float64](v1)
  1062  			_v2 := types.BytesToArray[float64](v2)
  1063  
  1064  			return moarray.Compare[float64](_v1, _v2) <= 0
  1065  		})
  1066  	case types.T_date:
  1067  		return opBinaryFixedFixedToFixed[types.Date, types.Date, bool](parameters, rs, proc, length, func(a, b types.Date) bool {
  1068  			return a <= b
  1069  		})
  1070  	case types.T_datetime:
  1071  		return opBinaryFixedFixedToFixed[types.Datetime, types.Datetime, bool](parameters, rs, proc, length, func(a, b types.Datetime) bool {
  1072  			return a <= b
  1073  		})
  1074  	case types.T_time:
  1075  		return opBinaryFixedFixedToFixed[types.Time, types.Time, bool](parameters, rs, proc, length, func(a, b types.Time) bool {
  1076  			return a <= b
  1077  		})
  1078  	case types.T_timestamp:
  1079  		return opBinaryFixedFixedToFixed[types.Timestamp, types.Timestamp, bool](parameters, rs, proc, length, func(a, b types.Timestamp) bool {
  1080  			return a <= b
  1081  		})
  1082  	case types.T_decimal64:
  1083  		return valueDec64Compare(parameters, rs, uint64(length), func(a, b types.Decimal64) bool {
  1084  			return a.Compare(b) <= 0
  1085  		})
  1086  	case types.T_decimal128:
  1087  		return valueDec128Compare(parameters, rs, uint64(length), func(a, b types.Decimal128) bool {
  1088  			return a.Compare(b) <= 0
  1089  		})
  1090  	case types.T_Rowid:
  1091  		return opBinaryFixedFixedToFixed[types.Rowid, types.Rowid, bool](parameters, rs, proc, length, func(a, b types.Rowid) bool {
  1092  			return a.Le(b)
  1093  		})
  1094  	}
  1095  	panic("unreached code")
  1096  }
  1097  
  1098  func operatorOpInt64Fn(
  1099  	parameters []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int,
  1100  	fn func(int64, int64) int64) error {
  1101  	p1 := vector.GenerateFunctionFixedTypeParameter[int64](parameters[0])
  1102  	p2 := vector.GenerateFunctionFixedTypeParameter[int64](parameters[1])
  1103  	rs := vector.MustFunctionResult[int64](result)
  1104  	for i := uint64(0); i < uint64(length); i++ {
  1105  		v1, null1 := p1.GetValue(i)
  1106  		v2, null2 := p2.GetValue(i)
  1107  		if err := rs.Append(fn(v1, v2), null1 || null2); err != nil {
  1108  			return err
  1109  		}
  1110  	}
  1111  	return nil
  1112  }
  1113  
  1114  func operatorOpStrFn(
  1115  	parameters []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int,
  1116  	fn func([]byte, []byte) ([]byte, error)) error {
  1117  	p1 := vector.GenerateFunctionStrParameter(parameters[0])
  1118  	p2 := vector.GenerateFunctionStrParameter(parameters[1])
  1119  	rs := vector.MustFunctionResult[types.Varlena](result)
  1120  	for i := uint64(0); i < uint64(length); i++ {
  1121  		v1, null1 := p1.GetStrValue(i)
  1122  		v2, null2 := p2.GetStrValue(i)
  1123  		if null1 || null2 {
  1124  			if err := rs.AppendBytes(nil, true); err != nil {
  1125  				return err
  1126  			}
  1127  		} else {
  1128  			rv, err := fn(v1, v2)
  1129  			if err != nil {
  1130  				return err
  1131  			}
  1132  			if err = rs.AppendBytes(rv, false); err != nil {
  1133  				return err
  1134  			}
  1135  		}
  1136  	}
  1137  	return nil
  1138  }
  1139  
  1140  func operatorOpBitAndInt64Fn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  1141  	return operatorOpInt64Fn(parameters, result, proc, length, func(i int64, i2 int64) int64 {
  1142  		return i & i2
  1143  	})
  1144  }
  1145  
  1146  func operatorOpBitAndStrFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  1147  	return operatorOpStrFn(parameters, result, proc, length, func(i []byte, i2 []byte) ([]byte, error) {
  1148  		if len(i) != len(i2) {
  1149  			return nil, moerr.NewInternalErrorNoCtx("Binary operands of bitwise operators must be of equal length")
  1150  		}
  1151  		rv := make([]byte, len(i))
  1152  		for j := range rv {
  1153  			rv[j] = i[j] & i2[j]
  1154  		}
  1155  		return rv, nil
  1156  	})
  1157  }
  1158  
  1159  func operatorOpBitXorInt64Fn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  1160  	return operatorOpInt64Fn(parameters, result, proc, length, func(i int64, i2 int64) int64 {
  1161  		return i ^ i2
  1162  	})
  1163  }
  1164  
  1165  func operatorOpBitXorStrFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  1166  	return operatorOpStrFn(parameters, result, proc, length, func(i []byte, i2 []byte) ([]byte, error) {
  1167  		if len(i) != len(i2) {
  1168  			return nil, moerr.NewInternalErrorNoCtx("Binary operands of bitwise operators must be of equal length")
  1169  		}
  1170  		rv := make([]byte, len(i))
  1171  		for j := range rv {
  1172  			rv[j] = i[j] ^ i2[j]
  1173  		}
  1174  		return rv, nil
  1175  	})
  1176  }
  1177  
  1178  func operatorOpBitOrInt64Fn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  1179  	return operatorOpInt64Fn(parameters, result, proc, length, func(i int64, i2 int64) int64 {
  1180  		return i | i2
  1181  	})
  1182  }
  1183  
  1184  func operatorOpBitOrStrFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  1185  	return operatorOpStrFn(parameters, result, proc, length, func(i []byte, i2 []byte) ([]byte, error) {
  1186  		if len(i) != len(i2) {
  1187  			return nil, moerr.NewInternalErrorNoCtx("Binary operands of bitwise operators must be of equal length")
  1188  		}
  1189  		rv := make([]byte, len(i))
  1190  		for j := range rv {
  1191  			rv[j] = i[j] | i2[j]
  1192  		}
  1193  		return rv, nil
  1194  	})
  1195  }
  1196  
  1197  func operatorOpBitShiftLeftInt64Fn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  1198  	return operatorOpInt64Fn(parameters, result, proc, length, func(i int64, i2 int64) int64 {
  1199  		if i2 < 0 {
  1200  			return 0
  1201  		}
  1202  		return i << i2
  1203  	})
  1204  }
  1205  
  1206  func operatorOpBitShiftRightInt64Fn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
  1207  	return operatorOpInt64Fn(parameters, result, proc, length, func(i int64, i2 int64) int64 {
  1208  		if i2 < 0 {
  1209  			return 0
  1210  		}
  1211  		return i >> i2
  1212  	})
  1213  }