github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/plan/function/operatorSet.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 "math" 19 20 "github.com/matrixorigin/matrixone/pkg/common/moerr" 21 "github.com/matrixorigin/matrixone/pkg/container/types" 22 "github.com/matrixorigin/matrixone/pkg/container/vector" 23 "github.com/matrixorigin/matrixone/pkg/vm/process" 24 "golang.org/x/exp/constraints" 25 ) 26 27 var ( 28 // operater `CASE` supported return type. 29 retOperatorCaseSupports = []types.T{ 30 types.T_int8, types.T_int16, types.T_int32, types.T_int64, 31 types.T_uint8, types.T_uint16, types.T_uint32, types.T_uint64, 32 types.T_float32, types.T_float64, 33 types.T_bool, 34 types.T_bit, 35 types.T_uuid, 36 types.T_date, types.T_datetime, types.T_timestamp, types.T_time, 37 types.T_decimal64, types.T_decimal128, 38 types.T_varchar, types.T_char, types.T_blob, types.T_text, types.T_json, 39 } 40 ) 41 42 // caseCheck check `case X then Y case X1 then Y1 ... (else Z)` 43 func caseCheck(_ []overload, inputs []types.Type) checkResult { 44 l := len(inputs) 45 46 needCast := false 47 if l >= 2 { 48 // X should be bool or Int. 49 for i := 0; i < l-1; i += 2 { 50 if inputs[i].Oid != types.T_bool { 51 if inputs[i].IsIntOrUint() { 52 needCast = true 53 } else { 54 return newCheckResultWithFailure(failedFunctionParametersWrong) 55 } 56 } 57 } 58 59 // Y should be cast to a same type. 60 //allYSame := true 61 //t := inputs[1] 62 // 63 //if l%2 == 1 { 64 // if inputs[l-1].Oid != t.Oid { 65 // allYSame = false 66 // } 67 //} 68 //if allYSame { 69 // for i := 1; i < l; i += 2 { 70 // if t.Oid != inputs[i].Oid { 71 // allYSame = false 72 // break 73 // } 74 // } 75 //} 76 77 // XXX choose a supported Y type. 78 var source []types.Type 79 minCost := math.MaxInt32 80 retType := types.Type{} 81 //if allYSame { 82 // source = []types.Type{inputs[1]} 83 //} else { 84 // source = make([]types.Type, 0, (l+1)/2) 85 // for j := 1; j < l; j += 2 { 86 // source = append(source, inputs[j]) 87 // } 88 // if l%2 == 1 { 89 // source = append(source, inputs[l-1]) 90 // } 91 //} 92 93 source = make([]types.Type, 0, (l+1)/2) 94 for j := 1; j < l; j += 2 { 95 source = append(source, inputs[j]) 96 } 97 if l%2 == 1 { 98 source = append(source, inputs[l-1]) 99 } 100 101 target := make([]types.T, len(source)) 102 103 for _, rett := range retOperatorCaseSupports { 104 for i := range target { 105 target[i] = rett 106 } 107 c, cost := tryToMatch(source, target) 108 if c == matchFailed { 109 continue 110 } 111 if cost < minCost { 112 minCost = cost 113 retType = rett.ToType() 114 if retType.Oid.IsDecimal() { 115 setMaxScaleFromSource(&retType, source) 116 } else if retType.Oid.IsMySQLString() { 117 setMaxWidthFromSource(&retType, source) 118 } 119 } 120 } 121 if minCost == math.MaxInt32 { 122 return newCheckResultWithFailure(failedFunctionParametersWrong) 123 } 124 if minCost == 0 && !needCast && !retType.Oid.IsMySQLString() { 125 return newCheckResultWithSuccess(0) 126 } 127 128 finalTypes := make([]types.Type, len(inputs)) 129 for i := range finalTypes { 130 if i%2 == 0 { 131 finalTypes[i] = types.T_bool.ToType() 132 } else { 133 finalTypes[i] = retType 134 } 135 } 136 if len(inputs)%2 == 1 { 137 finalTypes[len(finalTypes)-1] = retType 138 } 139 return newCheckResultWithCast(0, finalTypes) 140 } 141 return newCheckResultWithFailure(failedFunctionParametersWrong) 142 } 143 144 func caseFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error { 145 t := result.GetResultVector().GetType() 146 switch t.Oid { 147 case types.T_bit: 148 return generalCaseFn[uint64](parameters, result, proc, length) 149 case types.T_int8: 150 return generalCaseFn[int8](parameters, result, proc, length) 151 case types.T_int16: 152 return generalCaseFn[int16](parameters, result, proc, length) 153 case types.T_int32: 154 return generalCaseFn[int32](parameters, result, proc, length) 155 case types.T_int64: 156 return generalCaseFn[int64](parameters, result, proc, length) 157 case types.T_uint8: 158 return generalCaseFn[uint8](parameters, result, proc, length) 159 case types.T_uint16: 160 return generalCaseFn[uint16](parameters, result, proc, length) 161 case types.T_uint32: 162 return generalCaseFn[uint32](parameters, result, proc, length) 163 case types.T_uint64: 164 return generalCaseFn[uint64](parameters, result, proc, length) 165 case types.T_float32: 166 return generalCaseFn[float32](parameters, result, proc, length) 167 case types.T_float64: 168 return generalCaseFn[float64](parameters, result, proc, length) 169 case types.T_date: 170 return generalCaseFn[types.Date](parameters, result, proc, length) 171 case types.T_time: 172 return generalCaseFn[types.Time](parameters, result, proc, length) 173 case types.T_datetime: 174 return generalCaseFn[types.Datetime](parameters, result, proc, length) 175 case types.T_timestamp: 176 return generalCaseFn[types.Timestamp](parameters, result, proc, length) 177 case types.T_uuid: 178 return generalCaseFn[types.Uuid](parameters, result, proc, length) 179 case types.T_bool: 180 return generalCaseFn[bool](parameters, result, proc, length) 181 case types.T_decimal64: 182 return generalCaseFn[types.Decimal64](parameters, result, proc, length) 183 case types.T_decimal128: 184 return generalCaseFn[types.Decimal128](parameters, result, proc, length) 185 case types.T_enum: 186 return generalCaseFn[types.Enum](parameters, result, proc, length) 187 case types.T_char: 188 return strCaseFn(parameters, result, proc, length) 189 case types.T_varchar: 190 return strCaseFn(parameters, result, proc, length) 191 case types.T_blob: 192 return strCaseFn(parameters, result, proc, length) 193 case types.T_text: 194 return strCaseFn(parameters, result, proc, length) 195 case types.T_json: 196 return strCaseFn(parameters, result, proc, length) 197 } 198 panic("unreached code") 199 } 200 201 func generalCaseFn[T constraints.Integer | constraints.Float | bool | types.Date | types.Datetime | 202 types.Decimal64 | types.Decimal128 | types.Timestamp | types.Uuid](vecs []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int) error { 203 // case Xn then Yn else Z 204 xs := make([]vector.FunctionParameterWrapper[bool], 0, len(vecs)/2) 205 ys := make([]vector.FunctionParameterWrapper[T], 0, len(vecs)/2) 206 207 l := len(vecs) 208 for i := 0; i < l-1; i += 2 { 209 xs = append(xs, vector.GenerateFunctionFixedTypeParameter[bool](vecs[i])) 210 } 211 for j := 1; j < l; j += 2 { 212 ys = append(ys, vector.GenerateFunctionFixedTypeParameter[T](vecs[j])) 213 } 214 215 rs := vector.MustFunctionResult[T](result) 216 217 if len(vecs)%2 == 1 { 218 z := vector.GenerateFunctionFixedTypeParameter[T](vecs[len(vecs)-1]) 219 for i := uint64(0); i < uint64(length); i++ { 220 matchElse := true 221 for j := range xs { 222 if v, null := xs[j].GetValue(i); !null && v { 223 if err := rs.Append(ys[j].GetValue(i)); err != nil { 224 return err 225 } 226 matchElse = false 227 break 228 } 229 } 230 if matchElse { 231 if err := rs.Append(z.GetValue(i)); err != nil { 232 return err 233 } 234 } 235 } 236 } else { 237 var dv T // default value 238 239 for i := uint64(0); i < uint64(length); i++ { 240 matchElse := true 241 for j := range xs { 242 if v, null := xs[j].GetValue(i); !null && v { 243 if err := rs.Append(ys[j].GetValue(i)); err != nil { 244 return err 245 } 246 matchElse = false 247 break 248 } 249 } 250 if matchElse { 251 if err := rs.Append(dv, true); err != nil { 252 return err 253 } 254 } 255 } 256 } 257 return nil 258 } 259 260 func strCaseFn(vecs []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int) error { 261 // case Xn then Yn else Z 262 xs := make([]vector.FunctionParameterWrapper[bool], 0, len(vecs)/2) 263 ys := make([]vector.FunctionParameterWrapper[types.Varlena], 0, len(vecs)/2) 264 265 l := len(vecs) 266 for i := 0; i < l-1; i += 2 { 267 xs = append(xs, vector.GenerateFunctionFixedTypeParameter[bool](vecs[i])) 268 } 269 for j := 1; j < l; j += 2 { 270 ys = append(ys, vector.GenerateFunctionStrParameter(vecs[j])) 271 } 272 273 rs := vector.MustFunctionResult[types.Varlena](result) 274 275 if len(vecs)%2 == 1 { 276 z := vector.GenerateFunctionStrParameter(vecs[len(vecs)-1]) 277 for i := uint64(0); i < uint64(length); i++ { 278 matchElse := true 279 for j := range xs { 280 if v, null := xs[j].GetValue(i); !null && v { 281 if err := rs.AppendBytes(ys[j].GetStrValue(i)); err != nil { 282 return err 283 } 284 matchElse = false 285 break 286 } 287 } 288 if matchElse { 289 if err := rs.AppendBytes(z.GetStrValue(i)); err != nil { 290 return err 291 } 292 } 293 } 294 } else { 295 for i := uint64(0); i < uint64(length); i++ { 296 matchElse := true 297 for j := range xs { 298 if v, null := xs[j].GetValue(i); !null && v { 299 if err := rs.AppendBytes(ys[j].GetStrValue(i)); err != nil { 300 return err 301 } 302 matchElse = false 303 break 304 } 305 } 306 if matchElse { 307 if err := rs.AppendBytes(nil, true); err != nil { 308 return err 309 } 310 } 311 } 312 } 313 return nil 314 } 315 316 var ( 317 retOperatorIffSupports = []types.T{ 318 types.T_int8, types.T_int16, types.T_int32, types.T_int64, 319 types.T_uint8, types.T_uint16, types.T_uint32, types.T_uint64, 320 types.T_float32, types.T_float64, 321 types.T_uuid, 322 types.T_bool, types.T_date, types.T_datetime, 323 types.T_bit, 324 types.T_varchar, types.T_char, types.T_blob, types.T_text, types.T_json, 325 types.T_decimal64, types.T_decimal128, 326 types.T_timestamp, types.T_time, 327 } 328 ) 329 330 func iffCheck(_ []overload, inputs []types.Type) checkResult { 331 // iff(x, y, z) 332 if len(inputs) == 3 { 333 needCast := false 334 if inputs[0].Oid != types.T_bool { 335 if !inputs[0].IsIntOrUint() { 336 return newCheckResultWithFailure(failedFunctionParametersWrong) 337 } 338 needCast = true 339 } 340 341 minCost := math.MaxInt32 342 retType := types.Type{} 343 344 source := []types.Type{inputs[1], inputs[2]} 345 target := make([]types.T, 2) 346 for _, rett := range retOperatorIffSupports { 347 target[0], target[1] = rett, rett 348 349 c, cost := tryToMatch(source, target) 350 if c == matchFailed { 351 continue 352 } 353 if cost < minCost { 354 minCost = cost 355 retType = rett.ToType() 356 if retType.Oid.IsDecimal() { 357 setMaxScaleFromSource(&retType, source) 358 } else if retType.Oid.IsMySQLString() { 359 setMaxWidthFromSource(&retType, source) 360 } 361 } 362 } 363 364 if minCost == math.MaxInt32 { 365 return newCheckResultWithFailure(failedFunctionParametersWrong) 366 } 367 if minCost == 0 && !needCast && !retType.Oid.IsMySQLString() { 368 return newCheckResultWithSuccess(0) 369 } 370 return newCheckResultWithCast(0, []types.Type{types.T_bool.ToType(), retType, retType}) 371 } 372 return newCheckResultWithFailure(failedFunctionParametersWrong) 373 } 374 375 func iffFn(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error { 376 rett := result.GetResultVector().GetType() 377 switch rett.Oid { 378 case types.T_bit: 379 return generalIffFn[uint64](parameters, result, proc, length) 380 case types.T_int8: 381 return generalIffFn[int8](parameters, result, proc, length) 382 case types.T_int16: 383 return generalIffFn[int16](parameters, result, proc, length) 384 case types.T_int32: 385 return generalIffFn[int32](parameters, result, proc, length) 386 case types.T_int64: 387 return generalIffFn[int64](parameters, result, proc, length) 388 case types.T_uint8: 389 return generalIffFn[uint8](parameters, result, proc, length) 390 case types.T_uint16: 391 return generalIffFn[uint16](parameters, result, proc, length) 392 case types.T_uint32: 393 return generalIffFn[uint32](parameters, result, proc, length) 394 case types.T_uint64: 395 return generalIffFn[uint64](parameters, result, proc, length) 396 case types.T_float32: 397 return generalIffFn[float32](parameters, result, proc, length) 398 case types.T_float64: 399 return generalIffFn[float64](parameters, result, proc, length) 400 case types.T_uuid: 401 return generalIffFn[types.Uuid](parameters, result, proc, length) 402 case types.T_bool: 403 return generalIffFn[bool](parameters, result, proc, length) 404 case types.T_date: 405 return generalIffFn[types.Date](parameters, result, proc, length) 406 case types.T_datetime: 407 return generalIffFn[types.Datetime](parameters, result, proc, length) 408 case types.T_decimal64: 409 return generalIffFn[types.Decimal64](parameters, result, proc, length) 410 case types.T_decimal128: 411 return generalIffFn[types.Decimal128](parameters, result, proc, length) 412 case types.T_time: 413 return generalIffFn[types.Time](parameters, result, proc, length) 414 case types.T_timestamp: 415 return generalIffFn[types.Timestamp](parameters, result, proc, length) 416 case types.T_enum: 417 return generalIffFn[types.Enum](parameters, result, proc, length) 418 case types.T_char, types.T_varchar, types.T_blob, types.T_text, types.T_json: 419 return strIffFn(parameters, result, proc, length) 420 } 421 panic("unreached code") 422 } 423 424 func generalIffFn[T constraints.Integer | constraints.Float | bool | types.Date | types.Datetime | 425 types.Decimal64 | types.Decimal128 | types.Timestamp | types.Uuid](vecs []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int) error { 426 p1 := vector.GenerateFunctionFixedTypeParameter[bool](vecs[0]) 427 p2 := vector.GenerateFunctionFixedTypeParameter[T](vecs[1]) 428 p3 := vector.GenerateFunctionFixedTypeParameter[T](vecs[2]) 429 430 rs := vector.MustFunctionResult[T](result) 431 for i := uint64(0); i < uint64(length); i++ { 432 b, null := p1.GetValue(i) 433 if !null && b { 434 if err := rs.Append(p2.GetValue(i)); err != nil { 435 return err 436 } 437 } else { 438 if err := rs.Append(p3.GetValue(i)); err != nil { 439 return err 440 } 441 } 442 } 443 return nil 444 } 445 446 func strIffFn(vecs []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int) error { 447 p1 := vector.GenerateFunctionFixedTypeParameter[bool](vecs[0]) 448 p2 := vector.GenerateFunctionStrParameter(vecs[1]) 449 p3 := vector.GenerateFunctionStrParameter(vecs[2]) 450 451 rs := vector.MustFunctionResult[types.Varlena](result) 452 for i := uint64(0); i < uint64(length); i++ { 453 b, null := p1.GetValue(i) 454 if !null && b { 455 if err := rs.AppendBytes(p2.GetStrValue(i)); err != nil { 456 return err 457 } 458 } else { 459 if err := rs.AppendBytes(p3.GetStrValue(i)); err != nil { 460 return err 461 } 462 } 463 } 464 return nil 465 } 466 467 func operatorUnaryPlus[T constraints.Integer | constraints.Float | types.Decimal64 | types.Decimal128](parameters []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int) error { 468 p1 := vector.GenerateFunctionFixedTypeParameter[T](parameters[0]) 469 rs := vector.MustFunctionResult[T](result) 470 for i := uint64(0); i < uint64(length); i++ { 471 if err := rs.Append(p1.GetValue(i)); err != nil { 472 return err 473 } 474 } 475 return nil 476 } 477 478 func operatorUnaryMinus[T constraints.Signed | constraints.Float](parameters []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int) error { 479 p1 := vector.GenerateFunctionFixedTypeParameter[T](parameters[0]) 480 rs := vector.MustFunctionResult[T](result) 481 for i := uint64(0); i < uint64(length); i++ { 482 v, null := p1.GetValue(i) 483 if err := rs.Append(-v, null); err != nil { 484 return err 485 } 486 } 487 return nil 488 } 489 490 func operatorUnaryMinusDecimal64(parameters []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int) error { 491 p1 := vector.GenerateFunctionFixedTypeParameter[types.Decimal64](parameters[0]) 492 rs := vector.MustFunctionResult[types.Decimal64](result) 493 for i := uint64(0); i < uint64(length); i++ { 494 v, null := p1.GetValue(i) 495 if null { 496 if err := rs.Append(v, true); err != nil { 497 return err 498 } 499 } else { 500 if err := rs.Append(v.Minus(), false); err != nil { 501 return err 502 } 503 } 504 } 505 return nil 506 } 507 508 func operatorUnaryMinusDecimal128(parameters []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int) error { 509 p1 := vector.GenerateFunctionFixedTypeParameter[types.Decimal128](parameters[0]) 510 rs := vector.MustFunctionResult[types.Decimal128](result) 511 for i := uint64(0); i < uint64(length); i++ { 512 v, null := p1.GetValue(i) 513 if null { 514 if err := rs.Append(v, true); err != nil { 515 return err 516 } 517 } else { 518 if err := rs.Append(v.Minus(), false); err != nil { 519 return err 520 } 521 } 522 } 523 return nil 524 } 525 526 func funcBitInversion[T constraints.Integer](x T) uint64 { 527 if x > 0 { 528 n := uint64(x) 529 return ^n 530 } else { 531 return uint64(^x) 532 } 533 } 534 535 func operatorUnaryTilde[T constraints.Integer](parameters []*vector.Vector, result vector.FunctionResultWrapper, _ *process.Process, length int) error { 536 p1 := vector.GenerateFunctionFixedTypeParameter[T](parameters[0]) 537 rs := vector.MustFunctionResult[uint64](result) 538 for i := uint64(0); i < uint64(length); i++ { 539 v, null := p1.GetValue(i) 540 if null { 541 if err := rs.Append(0, true); err != nil { 542 return err 543 } 544 } else { 545 if err := rs.Append(funcBitInversion(v), null); err != nil { 546 return err 547 } 548 } 549 550 } 551 return nil 552 } 553 554 func operatorOpIs(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error { 555 if !parameters[1].IsConst() || parameters[1].IsConstNull() { 556 return moerr.NewInternalError(proc.Ctx, "second parameter of IS must be TRUE or FALSE") 557 } 558 p1 := vector.GenerateFunctionFixedTypeParameter[bool](parameters[0]) 559 p2 := vector.GenerateFunctionFixedTypeParameter[bool](parameters[1]) 560 rs := vector.MustFunctionResult[bool](result) 561 v2, _ := p2.GetValue(0) 562 if v2 { 563 for i := uint64(0); i < uint64(length); i++ { 564 v1, null1 := p1.GetValue(i) 565 if err := rs.Append(!null1 && v1, false); err != nil { 566 return err 567 } 568 } 569 } else { 570 for i := uint64(0); i < uint64(length); i++ { 571 v1, null1 := p1.GetValue(i) 572 if err := rs.Append(!null1 && !v1, false); err != nil { 573 return err 574 } 575 } 576 } 577 578 return nil 579 } 580 581 func operatorOpIsNot(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error { 582 if !parameters[1].IsConst() || parameters[1].IsConstNull() { 583 return moerr.NewInternalError(proc.Ctx, "second parameter of IS NOT must be TRUE or FALSE") 584 } 585 p1 := vector.GenerateFunctionFixedTypeParameter[bool](parameters[0]) 586 p2 := vector.GenerateFunctionFixedTypeParameter[bool](parameters[1]) 587 rs := vector.MustFunctionResult[bool](result) 588 v2, _ := p2.GetValue(0) 589 if v2 { 590 for i := uint64(0); i < uint64(length); i++ { 591 v1, null1 := p1.GetValue(i) 592 if err := rs.Append(null1 || !v1, false); err != nil { 593 return err 594 } 595 } 596 } else { 597 for i := uint64(0); i < uint64(length); i++ { 598 v1, null1 := p1.GetValue(i) 599 if err := rs.Append(null1 || v1, false); err != nil { 600 return err 601 } 602 } 603 } 604 605 return nil 606 } 607 608 func operatorOpIsNull(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error { 609 rs := vector.MustFunctionResult[bool](result) 610 611 if parameters[0].IsConst() { 612 val := parameters[0].IsConstNull() 613 for i := uint64(0); i < uint64(length); i++ { 614 if err := rs.Append(val, false); err != nil { 615 return err 616 } 617 } 618 return nil 619 } 620 621 null := parameters[0].GetNulls() 622 if null.IsEmpty() { 623 for i := uint64(0); i < uint64(length); i++ { 624 if err := rs.Append(false, false); err != nil { 625 return err 626 } 627 } 628 return nil 629 } 630 631 for i := uint64(0); i < uint64(length); i++ { 632 if err := rs.Append(null.Contains(i), false); err != nil { 633 return err 634 } 635 } 636 return nil 637 } 638 639 func operatorOpIsNotNull(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error { 640 rs := vector.MustFunctionResult[bool](result) 641 642 if parameters[0].IsConst() { 643 val := !parameters[0].IsConstNull() 644 for i := uint64(0); i < uint64(length); i++ { 645 if err := rs.Append(val, false); err != nil { 646 return err 647 } 648 } 649 return nil 650 } 651 652 null := parameters[0].GetNulls() 653 if !null.Any() { 654 for i := uint64(0); i < uint64(length); i++ { 655 if err := rs.Append(true, false); err != nil { 656 return err 657 } 658 } 659 return nil 660 } 661 662 for i := uint64(0); i < uint64(length); i++ { 663 if err := rs.Append(!null.Contains(i), false); err != nil { 664 return err 665 } 666 } 667 return nil 668 } 669 670 func operatorIsTrue(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error { 671 return funcIs(parameters, result, length, false, true) 672 } 673 674 func operatorIsFalse(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error { 675 return funcIs(parameters, result, length, false, false) 676 } 677 678 func operatorIsNotFalse(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error { 679 return funcIs(parameters, result, length, true, true) 680 } 681 682 func operatorIsNotTrue(parameters []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error { 683 return funcIs(parameters, result, length, true, false) 684 } 685 686 func funcIs(parameters []*vector.Vector, result vector.FunctionResultWrapper, length int, nullValue bool, require bool) error { 687 p1 := vector.GenerateFunctionFixedTypeParameter[bool](parameters[0]) 688 689 rs := vector.MustFunctionResult[bool](result) 690 for i := uint64(0); i < uint64(length); i++ { 691 v1, null1 := p1.GetValue(i) 692 if null1 { 693 if err := rs.Append(nullValue, false); err != nil { 694 return err 695 } 696 } else { 697 if err := rs.Append(v1 == require, false); err != nil { 698 return err 699 } 700 } 701 } 702 return nil 703 }