github.com/matrixorigin/matrixone@v0.7.0/pkg/sql/plan/function/operators.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 "context" 19 "math" 20 21 "github.com/matrixorigin/matrixone/pkg/container/types" 22 "github.com/matrixorigin/matrixone/pkg/container/vector" 23 "github.com/matrixorigin/matrixone/pkg/pb/plan" 24 "github.com/matrixorigin/matrixone/pkg/sql/plan/function/builtin/binary" 25 "github.com/matrixorigin/matrixone/pkg/sql/plan/function/operator" 26 "github.com/matrixorigin/matrixone/pkg/vm/process" 27 ) 28 29 func initOperators() { 30 var err error 31 32 for fid, fs := range operators { 33 err = appendFunction(context.Background(), fid, fs) 34 if err != nil { 35 panic(err) 36 } 37 } 38 } 39 40 // operators contains the operator function indexed by function id. 41 var operators = map[int]Functions{ 42 ISTRUE: { 43 Id: ISTRUE, 44 Flag: plan.Function_PRODUCE_NO_NULL, 45 Layout: IS_NULL_EXPRESSION, 46 Overloads: []Function{ 47 { 48 Index: 0, 49 Args: []types.T{ 50 types.T_bool, 51 }, 52 ReturnTyp: types.T_bool, 53 Fn: operator.IsTrue, 54 }, 55 }, 56 }, 57 ISNOTTRUE: { 58 Id: ISNOTTRUE, 59 Flag: plan.Function_PRODUCE_NO_NULL, 60 Layout: IS_NULL_EXPRESSION, 61 Overloads: []Function{ 62 { 63 Index: 0, 64 Args: []types.T{ 65 types.T_bool, 66 }, 67 ReturnTyp: types.T_bool, 68 Fn: operator.IsNotTrue, 69 }, 70 }, 71 }, 72 ISFALSE: { 73 Id: ISFALSE, 74 Flag: plan.Function_PRODUCE_NO_NULL, 75 Layout: IS_NULL_EXPRESSION, 76 Overloads: []Function{ 77 { 78 Index: 0, 79 Args: []types.T{ 80 types.T_bool, 81 }, 82 ReturnTyp: types.T_bool, 83 Fn: operator.IsFalse, 84 }, 85 }, 86 }, 87 ISNOTFALSE: { 88 Id: ISNOTFALSE, 89 Flag: plan.Function_PRODUCE_NO_NULL, 90 Layout: IS_NULL_EXPRESSION, 91 Overloads: []Function{ 92 { 93 Index: 0, 94 Args: []types.T{ 95 types.T_bool, 96 }, 97 ReturnTyp: types.T_bool, 98 Fn: operator.IsNotFalse, 99 }, 100 }, 101 }, 102 // is null operator 103 ISNULL: { 104 Id: ISNULL, 105 Flag: plan.Function_PRODUCE_NO_NULL, 106 Layout: IS_NULL_EXPRESSION, 107 Overloads: []Function{ 108 { 109 Index: 0, 110 Args: []types.T{ 111 types.T_uint8, 112 }, 113 ReturnTyp: types.T_bool, 114 Fn: operator.IsNull, 115 }, 116 { 117 Index: 1, 118 Args: []types.T{ 119 types.T_uint16, 120 }, 121 ReturnTyp: types.T_bool, 122 Fn: operator.IsNull, 123 }, 124 { 125 Index: 2, 126 Args: []types.T{ 127 types.T_uint32, 128 }, 129 ReturnTyp: types.T_bool, 130 Fn: operator.IsNull, 131 }, 132 { 133 Index: 3, 134 Args: []types.T{ 135 types.T_uint64, 136 }, 137 ReturnTyp: types.T_bool, 138 Fn: operator.IsNull, 139 }, 140 { 141 Index: 4, 142 Args: []types.T{ 143 types.T_int8, 144 }, 145 ReturnTyp: types.T_bool, 146 Fn: operator.IsNull, 147 }, 148 { 149 Index: 5, 150 Args: []types.T{ 151 types.T_int16, 152 }, 153 ReturnTyp: types.T_bool, 154 Fn: operator.IsNull, 155 }, 156 { 157 Index: 6, 158 Args: []types.T{ 159 types.T_int32, 160 }, 161 ReturnTyp: types.T_bool, 162 Fn: operator.IsNull, 163 }, 164 { 165 Index: 7, 166 Args: []types.T{ 167 types.T_int64, 168 }, 169 ReturnTyp: types.T_bool, 170 Fn: operator.IsNull, 171 }, 172 { 173 Index: 8, 174 Args: []types.T{ 175 types.T_float32, 176 }, 177 ReturnTyp: types.T_bool, 178 Fn: operator.IsNull, 179 }, 180 { 181 Index: 9, 182 Args: []types.T{ 183 types.T_float64, 184 }, 185 ReturnTyp: types.T_bool, 186 Fn: operator.IsNull, 187 }, 188 { 189 Index: 10, 190 Args: []types.T{ 191 types.T_decimal64, 192 }, 193 ReturnTyp: types.T_bool, 194 Fn: operator.IsNull, 195 }, 196 { 197 Index: 11, 198 Args: []types.T{ 199 types.T_decimal128, 200 }, 201 ReturnTyp: types.T_bool, 202 Fn: operator.IsNull, 203 }, 204 { 205 Index: 12, 206 Args: []types.T{ 207 types.T_varchar, 208 }, 209 ReturnTyp: types.T_bool, 210 Fn: operator.IsNull, 211 }, 212 { 213 Index: 13, 214 Args: []types.T{ 215 types.T_char, 216 }, 217 ReturnTyp: types.T_bool, 218 Fn: operator.IsNull, 219 }, 220 { 221 Index: 14, 222 Args: []types.T{ 223 types.T_date, 224 }, 225 ReturnTyp: types.T_bool, 226 Fn: operator.IsNull, 227 }, 228 { 229 Index: 15, 230 Args: []types.T{ 231 types.T_datetime, 232 }, 233 ReturnTyp: types.T_bool, 234 Fn: operator.IsNull, 235 }, 236 { 237 Index: 16, 238 Args: []types.T{ 239 types.T_bool, 240 }, 241 ReturnTyp: types.T_bool, 242 Fn: operator.IsNull, 243 }, 244 { 245 Index: 17, 246 Args: []types.T{ 247 types.T_blob, 248 }, 249 ReturnTyp: types.T_bool, 250 Fn: operator.IsNull, 251 }, 252 { 253 Index: 18, 254 Args: []types.T{ 255 types.T_json, 256 }, 257 ReturnTyp: types.T_bool, 258 Fn: operator.IsNull, 259 }, 260 { 261 Index: 19, 262 Args: []types.T{ 263 types.T_text, 264 }, 265 ReturnTyp: types.T_bool, 266 Fn: operator.IsNull, 267 }, 268 { 269 Index: 20, 270 Args: []types.T{ 271 types.T_time, 272 }, 273 ReturnTyp: types.T_bool, 274 Fn: operator.IsNull, 275 }, 276 }, 277 }, 278 279 ISNOTNULL: { 280 Id: ISNOTNULL, 281 Flag: plan.Function_PRODUCE_NO_NULL, 282 Layout: IS_NULL_EXPRESSION, 283 Overloads: []Function{ 284 { 285 Index: 0, 286 Args: []types.T{ 287 types.T_uint8, 288 }, 289 ReturnTyp: types.T_bool, 290 Fn: operator.IsNotNull, 291 }, 292 { 293 Index: 1, 294 Args: []types.T{ 295 types.T_uint16, 296 }, 297 ReturnTyp: types.T_bool, 298 Fn: operator.IsNotNull, 299 }, 300 { 301 Index: 2, 302 Args: []types.T{ 303 types.T_uint32, 304 }, 305 ReturnTyp: types.T_bool, 306 Fn: operator.IsNotNull, 307 }, 308 { 309 Index: 3, 310 Args: []types.T{ 311 types.T_uint64, 312 }, 313 ReturnTyp: types.T_bool, 314 Fn: operator.IsNotNull, 315 }, 316 { 317 Index: 4, 318 Args: []types.T{ 319 types.T_int8, 320 }, 321 ReturnTyp: types.T_bool, 322 Fn: operator.IsNotNull, 323 }, 324 { 325 Index: 5, 326 Args: []types.T{ 327 types.T_int16, 328 }, 329 ReturnTyp: types.T_bool, 330 Fn: operator.IsNotNull, 331 }, 332 { 333 Index: 6, 334 Args: []types.T{ 335 types.T_int32, 336 }, 337 ReturnTyp: types.T_bool, 338 Fn: operator.IsNotNull, 339 }, 340 { 341 Index: 7, 342 Args: []types.T{ 343 types.T_int64, 344 }, 345 ReturnTyp: types.T_bool, 346 Fn: operator.IsNotNull, 347 }, 348 { 349 Index: 8, 350 Args: []types.T{ 351 types.T_float32, 352 }, 353 ReturnTyp: types.T_bool, 354 Fn: operator.IsNotNull, 355 }, 356 { 357 Index: 9, 358 Args: []types.T{ 359 types.T_float64, 360 }, 361 ReturnTyp: types.T_bool, 362 Fn: operator.IsNotNull, 363 }, 364 { 365 Index: 10, 366 Args: []types.T{ 367 types.T_decimal64, 368 }, 369 ReturnTyp: types.T_bool, 370 Fn: operator.IsNotNull, 371 }, 372 { 373 Index: 11, 374 Args: []types.T{ 375 types.T_decimal128, 376 }, 377 ReturnTyp: types.T_bool, 378 Fn: operator.IsNotNull, 379 }, 380 { 381 Index: 12, 382 Args: []types.T{ 383 types.T_varchar, 384 }, 385 ReturnTyp: types.T_bool, 386 Fn: operator.IsNotNull, 387 }, 388 { 389 Index: 13, 390 Args: []types.T{ 391 types.T_char, 392 }, 393 ReturnTyp: types.T_bool, 394 Fn: operator.IsNotNull, 395 }, 396 { 397 Index: 14, 398 Args: []types.T{ 399 types.T_date, 400 }, 401 ReturnTyp: types.T_bool, 402 Fn: operator.IsNotNull, 403 }, 404 { 405 Index: 15, 406 Args: []types.T{ 407 types.T_datetime, 408 }, 409 ReturnTyp: types.T_bool, 410 Fn: operator.IsNotNull, 411 }, 412 { 413 Index: 16, 414 Args: []types.T{ 415 types.T_bool, 416 }, 417 ReturnTyp: types.T_bool, 418 Fn: operator.IsNotNull, 419 }, 420 { 421 Index: 17, 422 Args: []types.T{ 423 types.T_blob, 424 }, 425 ReturnTyp: types.T_bool, 426 Fn: operator.IsNotNull, 427 }, 428 { 429 Index: 18, 430 Args: []types.T{ 431 types.T_json, 432 }, 433 ReturnTyp: types.T_bool, 434 Fn: operator.IsNotNull, 435 }, 436 { 437 Index: 19, 438 Args: []types.T{ 439 types.T_text, 440 }, 441 ReturnTyp: types.T_bool, 442 Fn: operator.IsNotNull, 443 }, 444 { 445 Index: 20, 446 Args: []types.T{ 447 types.T_time, 448 }, 449 ReturnTyp: types.T_bool, 450 Fn: operator.IsNotNull, 451 }, 452 }, 453 }, 454 // comparison operator 455 IS: { 456 Id: IS, 457 Flag: plan.Function_STRICT, 458 Layout: COMPARISON_OPERATOR, 459 Overloads: []Function{ 460 { 461 Index: 0, 462 Args: []types.T{ 463 types.T_bool, 464 types.T_bool, 465 }, 466 ReturnTyp: types.T_bool, 467 Fn: operator.Is, 468 }, 469 }, 470 }, 471 REG_MATCH: { 472 Id: REG_MATCH, 473 Flag: plan.Function_STRICT, 474 Layout: COMPARISON_OPERATOR, 475 Overloads: []Function{ 476 { 477 Index: 0, 478 Args: []types.T{ 479 types.T_varchar, 480 types.T_varchar, 481 }, 482 ReturnTyp: types.T_bool, 483 Fn: operator.RegMatch, 484 }, 485 }, 486 }, 487 NOT_REG_MATCH: { 488 Id: NOT_REG_MATCH, 489 Flag: plan.Function_STRICT, 490 Layout: COMPARISON_OPERATOR, 491 Overloads: []Function{ 492 { 493 Index: 0, 494 Args: []types.T{ 495 types.T_varchar, 496 types.T_varchar, 497 }, 498 ReturnTyp: types.T_bool, 499 Fn: operator.NotRegMatch, 500 }, 501 }, 502 }, 503 OP_BIT_XOR: { 504 Id: OP_BIT_XOR, 505 Flag: plan.Function_STRICT, 506 Layout: COMPARISON_OPERATOR, 507 Overloads: []Function{ 508 { 509 Index: 0, 510 Args: []types.T{ 511 types.T_int64, 512 types.T_int64, 513 }, 514 ReturnTyp: types.T_int64, 515 Fn: operator.OpBitXorFun[int64], 516 }, 517 }, 518 }, 519 520 OP_BIT_OR: { 521 Id: OP_BIT_OR, 522 Flag: plan.Function_STRICT, 523 Layout: COMPARISON_OPERATOR, 524 Overloads: []Function{ 525 { 526 Index: 0, 527 Args: []types.T{ 528 types.T_int64, 529 types.T_int64, 530 }, 531 ReturnTyp: types.T_int64, 532 Fn: operator.OpBitOrFun[int64], 533 }, 534 }, 535 }, 536 537 OP_BIT_AND: { 538 Id: OP_BIT_AND, 539 Flag: plan.Function_STRICT, 540 Layout: COMPARISON_OPERATOR, 541 Overloads: []Function{ 542 { 543 Index: 0, 544 Args: []types.T{ 545 types.T_int64, 546 types.T_int64, 547 }, 548 ReturnTyp: types.T_int64, 549 Fn: operator.OpBitAndFun[int64], 550 }, 551 }, 552 }, 553 554 OP_BIT_SHIFT_RIGHT: { 555 Id: OP_BIT_SHIFT_RIGHT, 556 Flag: plan.Function_STRICT, 557 Layout: COMPARISON_OPERATOR, 558 Overloads: []Function{ 559 { 560 Index: 0, 561 Args: []types.T{ 562 types.T_int64, 563 types.T_int64, 564 }, 565 ReturnTyp: types.T_int64, 566 Fn: operator.OpBitRightShiftFun[int64], 567 }, 568 }, 569 }, 570 571 OP_BIT_SHIFT_LEFT: { 572 Id: OP_BIT_SHIFT_LEFT, 573 Flag: plan.Function_STRICT, 574 Layout: COMPARISON_OPERATOR, 575 Overloads: []Function{ 576 { 577 Index: 0, 578 Args: []types.T{ 579 types.T_int64, 580 types.T_int64, 581 }, 582 ReturnTyp: types.T_int64, 583 Fn: operator.OpBitLeftShiftFun[int64], 584 }, 585 }, 586 }, 587 588 ISNOT: { 589 Id: ISNOT, 590 Flag: plan.Function_STRICT, 591 Layout: COMPARISON_OPERATOR, 592 Overloads: []Function{ 593 { 594 Index: 0, 595 Args: []types.T{ 596 types.T_bool, 597 types.T_bool, 598 }, 599 ReturnTyp: types.T_bool, 600 Fn: operator.IsNot, 601 }, 602 }, 603 }, 604 605 EQUAL: { 606 Id: EQUAL, 607 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 608 Layout: COMPARISON_OPERATOR, 609 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 610 Overloads: []Function{ 611 { 612 Index: 0, 613 Args: []types.T{ 614 types.T_uint8, 615 types.T_uint8, 616 }, 617 ReturnTyp: types.T_bool, 618 Fn: operator.EqGeneral[uint8], 619 }, 620 { 621 Index: 1, 622 Args: []types.T{ 623 types.T_uint16, 624 types.T_uint16, 625 }, 626 ReturnTyp: types.T_bool, 627 Fn: operator.EqGeneral[uint16], 628 }, 629 { 630 Index: 2, 631 Args: []types.T{ 632 types.T_uint32, 633 types.T_uint32, 634 }, 635 ReturnTyp: types.T_bool, 636 Fn: operator.EqGeneral[uint32], 637 }, 638 { 639 Index: 3, 640 Args: []types.T{ 641 types.T_uint64, 642 types.T_uint64, 643 }, 644 ReturnTyp: types.T_bool, 645 Fn: operator.EqGeneral[uint64], 646 }, 647 { 648 Index: 4, 649 Args: []types.T{ 650 types.T_int8, 651 types.T_int8, 652 }, 653 ReturnTyp: types.T_bool, 654 Fn: operator.EqGeneral[int8], 655 }, 656 { 657 Index: 5, 658 Args: []types.T{ 659 types.T_int16, 660 types.T_int16, 661 }, 662 ReturnTyp: types.T_bool, 663 Fn: operator.EqGeneral[int16], 664 }, 665 { 666 Index: 6, 667 Args: []types.T{ 668 types.T_int32, 669 types.T_int32, 670 }, 671 ReturnTyp: types.T_bool, 672 Fn: operator.EqGeneral[int32], 673 }, 674 { 675 Index: 7, 676 Args: []types.T{ 677 types.T_int64, 678 types.T_int64, 679 }, 680 ReturnTyp: types.T_bool, 681 Fn: operator.EqGeneral[int64], 682 }, 683 { 684 Index: 8, 685 Args: []types.T{ 686 types.T_float32, 687 types.T_float32, 688 }, 689 ReturnTyp: types.T_bool, 690 Fn: operator.EqGeneral[float32], 691 }, 692 { 693 Index: 9, 694 Args: []types.T{ 695 types.T_float64, 696 types.T_float64, 697 }, 698 ReturnTyp: types.T_bool, 699 Fn: operator.EqGeneral[float64], 700 }, 701 { 702 Index: 10, 703 Args: []types.T{ 704 types.T_decimal64, 705 types.T_decimal64, 706 }, 707 ReturnTyp: types.T_bool, 708 Fn: operator.EqDecimal64, 709 }, 710 { 711 Index: 11, 712 Args: []types.T{ 713 types.T_decimal128, 714 types.T_decimal128, 715 }, 716 ReturnTyp: types.T_bool, 717 Fn: operator.EqDecimal128, 718 }, 719 { 720 Index: 12, 721 Args: []types.T{ 722 types.T_varchar, 723 types.T_varchar, 724 }, 725 ReturnTyp: types.T_bool, 726 Fn: operator.EqString, 727 }, 728 { 729 Index: 13, 730 Args: []types.T{ 731 types.T_char, 732 types.T_char, 733 }, 734 ReturnTyp: types.T_bool, 735 Fn: operator.EqString, 736 }, 737 { 738 Index: 14, 739 Args: []types.T{ 740 types.T_date, 741 types.T_date, 742 }, 743 ReturnTyp: types.T_bool, 744 Fn: operator.EqGeneral[types.Date], 745 }, 746 { 747 Index: 15, 748 Args: []types.T{ 749 types.T_datetime, 750 types.T_datetime, 751 }, 752 ReturnTyp: types.T_bool, 753 Fn: operator.EqGeneral[types.Datetime], 754 }, 755 { 756 Index: 16, 757 Args: []types.T{ 758 types.T_bool, 759 types.T_bool, 760 }, 761 ReturnTyp: types.T_bool, 762 Fn: operator.EqGeneral[bool], 763 }, 764 { 765 Index: 17, 766 Args: []types.T{ 767 types.T_timestamp, 768 types.T_timestamp, 769 }, 770 ReturnTyp: types.T_bool, 771 Fn: operator.EqGeneral[types.Timestamp], 772 }, 773 { 774 Index: 18, 775 Args: []types.T{ 776 types.T_blob, 777 types.T_blob, 778 }, 779 ReturnTyp: types.T_bool, 780 Fn: operator.EqString, 781 }, 782 { 783 Index: 19, 784 Args: []types.T{ 785 types.T_uuid, 786 types.T_uuid, 787 }, 788 ReturnTyp: types.T_bool, 789 Fn: operator.EqUuid, 790 }, 791 { 792 Index: 20, 793 Args: []types.T{ 794 types.T_text, 795 types.T_text, 796 }, 797 ReturnTyp: types.T_bool, 798 Fn: operator.EqString, 799 }, 800 { 801 Index: 21, 802 Args: []types.T{ 803 types.T_time, 804 types.T_time, 805 }, 806 ReturnTyp: types.T_bool, 807 Fn: operator.EqGeneral[types.Time], 808 }, 809 { 810 Index: 22, 811 Args: []types.T{ 812 types.T_json, 813 types.T_json, 814 }, 815 ReturnTyp: types.T_bool, 816 Fn: operator.EqString, 817 }, 818 }, 819 }, 820 821 IN: { 822 Id: IN, 823 Flag: plan.Function_STRICT, 824 Layout: IN_PREDICATE, 825 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 826 Overloads: []Function{ 827 { 828 Index: 0, 829 Args: []types.T{ 830 types.T_uint8, 831 types.T_tuple, 832 }, 833 ReturnTyp: types.T_bool, 834 Fn: operator.INGeneral[uint8], 835 }, 836 { 837 Index: 1, 838 Args: []types.T{ 839 types.T_uint16, 840 types.T_tuple, 841 }, 842 ReturnTyp: types.T_bool, 843 Fn: operator.INGeneral[uint16], 844 }, 845 { 846 Index: 2, 847 Args: []types.T{ 848 types.T_uint32, 849 types.T_tuple, 850 }, 851 ReturnTyp: types.T_bool, 852 Fn: operator.INGeneral[uint32], 853 }, 854 { 855 Index: 3, 856 Args: []types.T{ 857 types.T_uint64, 858 types.T_tuple, 859 }, 860 ReturnTyp: types.T_bool, 861 Fn: operator.INGeneral[uint64], 862 }, 863 { 864 Index: 4, 865 Args: []types.T{ 866 types.T_int8, 867 types.T_tuple, 868 }, 869 ReturnTyp: types.T_bool, 870 Fn: operator.INGeneral[int8], 871 }, 872 { 873 Index: 5, 874 Args: []types.T{ 875 types.T_int16, 876 types.T_tuple, 877 }, 878 ReturnTyp: types.T_bool, 879 Fn: operator.INGeneral[int16], 880 }, 881 { 882 Index: 6, 883 Args: []types.T{ 884 types.T_int32, 885 types.T_tuple, 886 }, 887 ReturnTyp: types.T_bool, 888 Fn: operator.INGeneral[int32], 889 }, 890 { 891 Index: 7, 892 Args: []types.T{ 893 types.T_int64, 894 types.T_tuple, 895 }, 896 ReturnTyp: types.T_bool, 897 Fn: operator.INGeneral[int64], 898 }, 899 { 900 Index: 8, 901 Args: []types.T{ 902 types.T_float32, 903 types.T_tuple, 904 }, 905 ReturnTyp: types.T_bool, 906 Fn: operator.INGeneral[float32], 907 }, 908 { 909 Index: 9, 910 Args: []types.T{ 911 types.T_float64, 912 types.T_tuple, 913 }, 914 ReturnTyp: types.T_bool, 915 Fn: operator.INGeneral[float64], 916 }, 917 { 918 Index: 10, 919 Args: []types.T{ 920 types.T_decimal64, 921 types.T_tuple, 922 }, 923 ReturnTyp: types.T_bool, 924 Fn: nil, 925 }, 926 { 927 Index: 11, 928 Args: []types.T{ 929 types.T_decimal128, 930 types.T_tuple, 931 }, 932 ReturnTyp: types.T_bool, 933 Fn: nil, 934 }, 935 { 936 Index: 12, 937 Args: []types.T{ 938 types.T_varchar, 939 types.T_tuple, 940 }, 941 ReturnTyp: types.T_bool, 942 Fn: operator.INString, 943 }, 944 { 945 Index: 13, 946 Args: []types.T{ 947 types.T_char, 948 types.T_tuple, 949 }, 950 ReturnTyp: types.T_bool, 951 Fn: operator.INString, 952 }, 953 { 954 Index: 14, 955 Args: []types.T{ 956 types.T_date, 957 types.T_tuple, 958 }, 959 ReturnTyp: types.T_bool, 960 Fn: operator.INGeneral[types.Date], 961 }, 962 { 963 Index: 15, 964 Args: []types.T{ 965 types.T_datetime, 966 types.T_tuple, 967 }, 968 ReturnTyp: types.T_bool, 969 Fn: operator.INGeneral[types.Datetime], 970 }, 971 { 972 Index: 16, 973 Args: []types.T{ 974 types.T_bool, 975 types.T_tuple, 976 }, 977 ReturnTyp: types.T_bool, 978 Fn: operator.INGeneral[bool], 979 }, 980 { 981 Index: 17, 982 Args: []types.T{ 983 types.T_timestamp, 984 types.T_tuple, 985 }, 986 ReturnTyp: types.T_bool, 987 Fn: operator.INGeneral[types.Timestamp], 988 }, 989 { 990 Index: 18, 991 Args: []types.T{ 992 types.T_blob, 993 types.T_tuple, 994 }, 995 ReturnTyp: types.T_bool, 996 Fn: nil, 997 }, 998 { 999 Index: 19, 1000 Args: []types.T{ 1001 types.T_uuid, 1002 types.T_tuple, 1003 }, 1004 ReturnTyp: types.T_bool, 1005 Fn: nil, 1006 }, 1007 { 1008 Index: 20, 1009 Args: []types.T{ 1010 types.T_text, 1011 types.T_tuple, 1012 }, 1013 ReturnTyp: types.T_bool, 1014 Fn: operator.INString, 1015 }, 1016 { 1017 Index: 21, 1018 Args: []types.T{ 1019 types.T_time, 1020 types.T_tuple, 1021 }, 1022 ReturnTyp: types.T_bool, 1023 Fn: operator.INGeneral[types.Time], 1024 }, 1025 }, 1026 }, 1027 1028 NOT_IN: { 1029 Id: NOT_IN, 1030 Flag: plan.Function_STRICT, 1031 Layout: IN_PREDICATE, 1032 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 1033 Overloads: []Function{ 1034 { 1035 Index: 0, 1036 Args: []types.T{ 1037 types.T_uint8, 1038 types.T_tuple, 1039 }, 1040 ReturnTyp: types.T_bool, 1041 Fn: operator.NotINGeneral[uint8], 1042 }, 1043 { 1044 Index: 1, 1045 Args: []types.T{ 1046 types.T_uint16, 1047 types.T_tuple, 1048 }, 1049 ReturnTyp: types.T_bool, 1050 Fn: operator.NotINGeneral[uint16], 1051 }, 1052 { 1053 Index: 2, 1054 Args: []types.T{ 1055 types.T_uint32, 1056 types.T_tuple, 1057 }, 1058 ReturnTyp: types.T_bool, 1059 Fn: operator.NotINGeneral[uint32], 1060 }, 1061 { 1062 Index: 3, 1063 Args: []types.T{ 1064 types.T_uint64, 1065 types.T_tuple, 1066 }, 1067 ReturnTyp: types.T_bool, 1068 Fn: operator.NotINGeneral[uint64], 1069 }, 1070 { 1071 Index: 4, 1072 Args: []types.T{ 1073 types.T_int8, 1074 types.T_tuple, 1075 }, 1076 ReturnTyp: types.T_bool, 1077 Fn: operator.NotINGeneral[int8], 1078 }, 1079 { 1080 Index: 5, 1081 Args: []types.T{ 1082 types.T_int16, 1083 types.T_tuple, 1084 }, 1085 ReturnTyp: types.T_bool, 1086 Fn: operator.NotINGeneral[int16], 1087 }, 1088 { 1089 Index: 6, 1090 Args: []types.T{ 1091 types.T_int32, 1092 types.T_tuple, 1093 }, 1094 ReturnTyp: types.T_bool, 1095 Fn: operator.NotINGeneral[int32], 1096 }, 1097 { 1098 Index: 7, 1099 Args: []types.T{ 1100 types.T_int64, 1101 types.T_tuple, 1102 }, 1103 ReturnTyp: types.T_bool, 1104 Fn: operator.NotINGeneral[int64], 1105 }, 1106 { 1107 Index: 8, 1108 Args: []types.T{ 1109 types.T_float32, 1110 types.T_tuple, 1111 }, 1112 ReturnTyp: types.T_bool, 1113 Fn: operator.NotINGeneral[float32], 1114 }, 1115 { 1116 Index: 9, 1117 Args: []types.T{ 1118 types.T_float64, 1119 types.T_tuple, 1120 }, 1121 ReturnTyp: types.T_bool, 1122 Fn: operator.NotINGeneral[float64], 1123 }, 1124 { 1125 Index: 10, 1126 Args: []types.T{ 1127 types.T_decimal64, 1128 types.T_tuple, 1129 }, 1130 ReturnTyp: types.T_bool, 1131 Fn: nil, 1132 }, 1133 { 1134 Index: 11, 1135 Args: []types.T{ 1136 types.T_decimal128, 1137 types.T_tuple, 1138 }, 1139 ReturnTyp: types.T_bool, 1140 Fn: nil, 1141 }, 1142 { 1143 Index: 12, 1144 Args: []types.T{ 1145 types.T_varchar, 1146 types.T_tuple, 1147 }, 1148 ReturnTyp: types.T_bool, 1149 Fn: operator.NotINString, 1150 }, 1151 { 1152 Index: 13, 1153 Args: []types.T{ 1154 types.T_char, 1155 types.T_tuple, 1156 }, 1157 ReturnTyp: types.T_bool, 1158 Fn: operator.NotINString, 1159 }, 1160 { 1161 Index: 14, 1162 Args: []types.T{ 1163 types.T_date, 1164 types.T_tuple, 1165 }, 1166 ReturnTyp: types.T_bool, 1167 Fn: operator.NotINGeneral[types.Date], 1168 }, 1169 { 1170 Index: 15, 1171 Args: []types.T{ 1172 types.T_datetime, 1173 types.T_tuple, 1174 }, 1175 ReturnTyp: types.T_bool, 1176 Fn: operator.NotINGeneral[types.Datetime], 1177 }, 1178 { 1179 Index: 16, 1180 Args: []types.T{ 1181 types.T_bool, 1182 types.T_tuple, 1183 }, 1184 ReturnTyp: types.T_bool, 1185 Fn: operator.NotINGeneral[bool], 1186 }, 1187 { 1188 Index: 17, 1189 Args: []types.T{ 1190 types.T_timestamp, 1191 types.T_tuple, 1192 }, 1193 ReturnTyp: types.T_bool, 1194 Fn: operator.NotINGeneral[types.Timestamp], 1195 }, 1196 { 1197 Index: 18, 1198 Args: []types.T{ 1199 types.T_blob, 1200 types.T_tuple, 1201 }, 1202 ReturnTyp: types.T_bool, 1203 Fn: nil, 1204 }, 1205 { 1206 Index: 19, 1207 Args: []types.T{ 1208 types.T_uuid, 1209 types.T_tuple, 1210 }, 1211 ReturnTyp: types.T_bool, 1212 Fn: nil, 1213 }, 1214 { 1215 Index: 20, 1216 Args: []types.T{ 1217 types.T_text, 1218 types.T_tuple, 1219 }, 1220 ReturnTyp: types.T_bool, 1221 Fn: operator.NotINString, 1222 }, 1223 { 1224 Index: 21, 1225 Args: []types.T{ 1226 types.T_time, 1227 types.T_tuple, 1228 }, 1229 ReturnTyp: types.T_bool, 1230 Fn: operator.NotINGeneral[types.Time], 1231 }, 1232 }, 1233 }, 1234 1235 GREAT_THAN: { 1236 Id: GREAT_THAN, 1237 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 1238 Layout: COMPARISON_OPERATOR, 1239 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 1240 Overloads: []Function{ 1241 { 1242 Index: 0, 1243 Args: []types.T{ 1244 types.T_uint8, 1245 types.T_uint8, 1246 }, 1247 ReturnTyp: types.T_bool, 1248 Fn: operator.GtGeneral[uint8], 1249 }, 1250 { 1251 Index: 1, 1252 Args: []types.T{ 1253 types.T_uint16, 1254 types.T_uint16, 1255 }, 1256 ReturnTyp: types.T_bool, 1257 Fn: operator.GtGeneral[uint16], 1258 }, 1259 { 1260 Index: 2, 1261 Args: []types.T{ 1262 types.T_uint32, 1263 types.T_uint32, 1264 }, 1265 ReturnTyp: types.T_bool, 1266 Fn: operator.GtGeneral[uint32], 1267 }, 1268 { 1269 Index: 3, 1270 Args: []types.T{ 1271 types.T_uint64, 1272 types.T_uint64, 1273 }, 1274 ReturnTyp: types.T_bool, 1275 Fn: operator.GtGeneral[uint64], 1276 }, 1277 { 1278 Index: 4, 1279 Args: []types.T{ 1280 types.T_int8, 1281 types.T_int8, 1282 }, 1283 ReturnTyp: types.T_bool, 1284 Fn: operator.GtGeneral[int8], 1285 }, 1286 { 1287 Index: 5, 1288 Args: []types.T{ 1289 types.T_int16, 1290 types.T_int16, 1291 }, 1292 ReturnTyp: types.T_bool, 1293 Fn: operator.GtGeneral[int16], 1294 }, 1295 { 1296 Index: 6, 1297 Args: []types.T{ 1298 types.T_int32, 1299 types.T_int32, 1300 }, 1301 ReturnTyp: types.T_bool, 1302 Fn: operator.GtGeneral[int32], 1303 }, 1304 { 1305 Index: 7, 1306 Args: []types.T{ 1307 types.T_int64, 1308 types.T_int64, 1309 }, 1310 ReturnTyp: types.T_bool, 1311 Fn: operator.GtGeneral[int64], 1312 }, 1313 { 1314 Index: 8, 1315 Args: []types.T{ 1316 types.T_float32, 1317 types.T_float32, 1318 }, 1319 ReturnTyp: types.T_bool, 1320 Fn: operator.GtGeneral[float32], 1321 }, 1322 { 1323 Index: 9, 1324 Args: []types.T{ 1325 types.T_float64, 1326 types.T_float64, 1327 }, 1328 ReturnTyp: types.T_bool, 1329 Fn: operator.GtGeneral[float64], 1330 }, 1331 { 1332 Index: 10, 1333 Args: []types.T{ 1334 types.T_decimal64, 1335 types.T_decimal64, 1336 }, 1337 ReturnTyp: types.T_bool, 1338 Fn: operator.GtDecimal64, 1339 }, 1340 { 1341 Index: 11, 1342 Args: []types.T{ 1343 types.T_decimal128, 1344 types.T_decimal128, 1345 }, 1346 ReturnTyp: types.T_bool, 1347 Fn: operator.GtDecimal128, 1348 }, 1349 { 1350 Index: 12, 1351 Args: []types.T{ 1352 types.T_varchar, 1353 types.T_varchar, 1354 }, 1355 ReturnTyp: types.T_bool, 1356 Fn: operator.GtString, 1357 }, 1358 { 1359 Index: 13, 1360 Args: []types.T{ 1361 types.T_char, 1362 types.T_char, 1363 }, 1364 ReturnTyp: types.T_bool, 1365 Fn: operator.GtString, 1366 }, 1367 { 1368 Index: 14, 1369 Args: []types.T{ 1370 types.T_date, 1371 types.T_date, 1372 }, 1373 ReturnTyp: types.T_bool, 1374 Fn: operator.GtGeneral[types.Date], 1375 }, 1376 { 1377 Index: 15, 1378 Args: []types.T{ 1379 types.T_datetime, 1380 types.T_datetime, 1381 }, 1382 ReturnTyp: types.T_bool, 1383 Fn: operator.GtGeneral[types.Datetime], 1384 }, 1385 { 1386 Index: 16, 1387 Args: []types.T{ 1388 types.T_bool, 1389 types.T_bool, 1390 }, 1391 ReturnTyp: types.T_bool, 1392 Fn: operator.GtGeneral[bool], 1393 }, 1394 { 1395 Index: 17, 1396 Args: []types.T{ 1397 types.T_timestamp, 1398 types.T_timestamp, 1399 }, 1400 ReturnTyp: types.T_bool, 1401 Fn: operator.GtGeneral[types.Timestamp], 1402 }, 1403 { 1404 Index: 18, 1405 Args: []types.T{ 1406 types.T_blob, 1407 types.T_blob, 1408 }, 1409 ReturnTyp: types.T_bool, 1410 Fn: operator.GtString, 1411 }, 1412 { 1413 Index: 19, 1414 Args: []types.T{ 1415 types.T_uuid, 1416 types.T_uuid, 1417 }, 1418 ReturnTyp: types.T_bool, 1419 Fn: operator.GtUuid, 1420 }, 1421 { 1422 Index: 20, 1423 Args: []types.T{ 1424 types.T_text, 1425 types.T_text, 1426 }, 1427 ReturnTyp: types.T_bool, 1428 Fn: operator.GtString, 1429 }, 1430 { 1431 Index: 21, 1432 Args: []types.T{ 1433 types.T_time, 1434 types.T_time, 1435 }, 1436 ReturnTyp: types.T_bool, 1437 Fn: operator.GtGeneral[types.Time], 1438 }, 1439 }, 1440 }, 1441 1442 GREAT_EQUAL: { 1443 Id: GREAT_EQUAL, 1444 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 1445 Layout: COMPARISON_OPERATOR, 1446 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 1447 Overloads: []Function{ 1448 { 1449 Index: 0, 1450 Args: []types.T{ 1451 types.T_uint8, 1452 types.T_uint8, 1453 }, 1454 ReturnTyp: types.T_bool, 1455 Fn: operator.GeGeneral[uint8], 1456 }, 1457 { 1458 Index: 1, 1459 Args: []types.T{ 1460 types.T_uint16, 1461 types.T_uint16, 1462 }, 1463 ReturnTyp: types.T_bool, 1464 Fn: operator.GeGeneral[uint16], 1465 }, 1466 { 1467 Index: 2, 1468 Args: []types.T{ 1469 types.T_uint32, 1470 types.T_uint32, 1471 }, 1472 ReturnTyp: types.T_bool, 1473 Fn: operator.GeGeneral[uint32], 1474 }, 1475 { 1476 Index: 3, 1477 Args: []types.T{ 1478 types.T_uint64, 1479 types.T_uint64, 1480 }, 1481 ReturnTyp: types.T_bool, 1482 Fn: operator.GeGeneral[uint64], 1483 }, 1484 { 1485 Index: 4, 1486 Args: []types.T{ 1487 types.T_int8, 1488 types.T_int8, 1489 }, 1490 ReturnTyp: types.T_bool, 1491 Fn: operator.GeGeneral[int8], 1492 }, 1493 { 1494 Index: 5, 1495 Args: []types.T{ 1496 types.T_int16, 1497 types.T_int16, 1498 }, 1499 ReturnTyp: types.T_bool, 1500 Fn: operator.GeGeneral[int16], 1501 }, 1502 { 1503 Index: 6, 1504 Args: []types.T{ 1505 types.T_int32, 1506 types.T_int32, 1507 }, 1508 ReturnTyp: types.T_bool, 1509 Fn: operator.GeGeneral[int32], 1510 }, 1511 { 1512 Index: 7, 1513 Args: []types.T{ 1514 types.T_int64, 1515 types.T_int64, 1516 }, 1517 ReturnTyp: types.T_bool, 1518 Fn: operator.GeGeneral[int64], 1519 }, 1520 { 1521 Index: 8, 1522 Args: []types.T{ 1523 types.T_float32, 1524 types.T_float32, 1525 }, 1526 ReturnTyp: types.T_bool, 1527 Fn: operator.GeGeneral[float32], 1528 }, 1529 { 1530 Index: 9, 1531 Args: []types.T{ 1532 types.T_float64, 1533 types.T_float64, 1534 }, 1535 ReturnTyp: types.T_bool, 1536 Fn: operator.GeGeneral[float64], 1537 }, 1538 { 1539 Index: 10, 1540 Args: []types.T{ 1541 types.T_decimal64, 1542 types.T_decimal64, 1543 }, 1544 ReturnTyp: types.T_bool, 1545 Fn: operator.GeDecimal64, 1546 }, 1547 { 1548 Index: 11, 1549 Args: []types.T{ 1550 types.T_decimal128, 1551 types.T_decimal128, 1552 }, 1553 ReturnTyp: types.T_bool, 1554 Fn: operator.GeDecimal128, 1555 }, 1556 { 1557 Index: 12, 1558 Args: []types.T{ 1559 types.T_varchar, 1560 types.T_varchar, 1561 }, 1562 ReturnTyp: types.T_bool, 1563 Fn: operator.GeString, 1564 }, 1565 { 1566 Index: 13, 1567 Args: []types.T{ 1568 types.T_char, 1569 types.T_char, 1570 }, 1571 ReturnTyp: types.T_bool, 1572 Fn: operator.GeString, 1573 }, 1574 { 1575 Index: 14, 1576 Args: []types.T{ 1577 types.T_date, 1578 types.T_date, 1579 }, 1580 ReturnTyp: types.T_bool, 1581 Fn: operator.GeGeneral[types.Date], 1582 }, 1583 { 1584 Index: 15, 1585 Args: []types.T{ 1586 types.T_datetime, 1587 types.T_datetime, 1588 }, 1589 ReturnTyp: types.T_bool, 1590 Fn: operator.GeGeneral[types.Datetime], 1591 }, 1592 { 1593 Index: 16, 1594 Args: []types.T{ 1595 types.T_bool, 1596 types.T_bool, 1597 }, 1598 ReturnTyp: types.T_bool, 1599 Fn: operator.GeGeneral[bool], 1600 }, 1601 { 1602 Index: 17, 1603 Args: []types.T{ 1604 types.T_timestamp, 1605 types.T_timestamp, 1606 }, 1607 ReturnTyp: types.T_bool, 1608 Fn: operator.GeGeneral[types.Timestamp], 1609 }, 1610 { 1611 Index: 18, 1612 Args: []types.T{ 1613 types.T_blob, 1614 types.T_blob, 1615 }, 1616 ReturnTyp: types.T_bool, 1617 Fn: operator.GeString, 1618 }, 1619 { 1620 Index: 19, 1621 Args: []types.T{ 1622 types.T_uuid, 1623 types.T_uuid, 1624 }, 1625 ReturnTyp: types.T_bool, 1626 Fn: operator.GeUuid, 1627 }, 1628 { 1629 Index: 20, 1630 Args: []types.T{ 1631 types.T_text, 1632 types.T_text, 1633 }, 1634 ReturnTyp: types.T_bool, 1635 Fn: operator.GeString, 1636 }, 1637 { 1638 Index: 21, 1639 Args: []types.T{ 1640 types.T_time, 1641 types.T_time, 1642 }, 1643 ReturnTyp: types.T_bool, 1644 Fn: operator.GeGeneral[types.Time], 1645 }, 1646 }, 1647 }, 1648 1649 LESS_THAN: { 1650 Id: LESS_THAN, 1651 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 1652 Layout: COMPARISON_OPERATOR, 1653 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 1654 Overloads: []Function{ 1655 { 1656 Index: 0, 1657 Args: []types.T{ 1658 types.T_uint8, 1659 types.T_uint8, 1660 }, 1661 ReturnTyp: types.T_bool, 1662 Fn: operator.LtGeneral[uint8], 1663 }, 1664 { 1665 Index: 1, 1666 Args: []types.T{ 1667 types.T_uint16, 1668 types.T_uint16, 1669 }, 1670 ReturnTyp: types.T_bool, 1671 Fn: operator.LtGeneral[uint16], 1672 }, 1673 { 1674 Index: 2, 1675 Args: []types.T{ 1676 types.T_uint32, 1677 types.T_uint32, 1678 }, 1679 ReturnTyp: types.T_bool, 1680 Fn: operator.LtGeneral[uint32], 1681 }, 1682 { 1683 Index: 3, 1684 Args: []types.T{ 1685 types.T_uint64, 1686 types.T_uint64, 1687 }, 1688 ReturnTyp: types.T_bool, 1689 Fn: operator.LtGeneral[uint64], 1690 }, 1691 { 1692 Index: 4, 1693 Args: []types.T{ 1694 types.T_int8, 1695 types.T_int8, 1696 }, 1697 ReturnTyp: types.T_bool, 1698 Fn: operator.LtGeneral[int8], 1699 }, 1700 { 1701 Index: 5, 1702 Args: []types.T{ 1703 types.T_int16, 1704 types.T_int16, 1705 }, 1706 ReturnTyp: types.T_bool, 1707 Fn: operator.LtGeneral[int16], 1708 }, 1709 { 1710 Index: 6, 1711 Args: []types.T{ 1712 types.T_int32, 1713 types.T_int32, 1714 }, 1715 ReturnTyp: types.T_bool, 1716 Fn: operator.LtGeneral[int32], 1717 }, 1718 { 1719 Index: 7, 1720 Args: []types.T{ 1721 types.T_int64, 1722 types.T_int64, 1723 }, 1724 ReturnTyp: types.T_bool, 1725 Fn: operator.LtGeneral[int64], 1726 }, 1727 { 1728 Index: 8, 1729 Args: []types.T{ 1730 types.T_float32, 1731 types.T_float32, 1732 }, 1733 ReturnTyp: types.T_bool, 1734 Fn: operator.LtGeneral[float32], 1735 }, 1736 { 1737 Index: 9, 1738 Args: []types.T{ 1739 types.T_float64, 1740 types.T_float64, 1741 }, 1742 ReturnTyp: types.T_bool, 1743 Fn: operator.LtGeneral[float64], 1744 }, 1745 { 1746 Index: 10, 1747 Args: []types.T{ 1748 types.T_decimal64, 1749 types.T_decimal64, 1750 }, 1751 ReturnTyp: types.T_bool, 1752 Fn: operator.LtDecimal64, 1753 }, 1754 { 1755 Index: 11, 1756 Args: []types.T{ 1757 types.T_decimal128, 1758 types.T_decimal128, 1759 }, 1760 ReturnTyp: types.T_bool, 1761 Fn: operator.LtDecimal128, 1762 }, 1763 { 1764 Index: 12, 1765 Args: []types.T{ 1766 types.T_varchar, 1767 types.T_varchar, 1768 }, 1769 ReturnTyp: types.T_bool, 1770 Fn: operator.LtString, 1771 }, 1772 { 1773 Index: 13, 1774 Args: []types.T{ 1775 types.T_char, 1776 types.T_char, 1777 }, 1778 ReturnTyp: types.T_bool, 1779 Fn: operator.LtString, 1780 }, 1781 { 1782 Index: 14, 1783 Args: []types.T{ 1784 types.T_date, 1785 types.T_date, 1786 }, 1787 ReturnTyp: types.T_bool, 1788 Fn: operator.LtGeneral[types.Date], 1789 }, 1790 { 1791 Index: 15, 1792 Args: []types.T{ 1793 types.T_datetime, 1794 types.T_datetime, 1795 }, 1796 ReturnTyp: types.T_bool, 1797 Fn: operator.LtGeneral[types.Datetime], 1798 }, 1799 { 1800 Index: 16, 1801 Args: []types.T{ 1802 types.T_bool, 1803 types.T_bool, 1804 }, 1805 ReturnTyp: types.T_bool, 1806 Fn: operator.LtGeneral[bool], 1807 }, 1808 { 1809 Index: 17, 1810 Args: []types.T{ 1811 types.T_timestamp, 1812 types.T_timestamp, 1813 }, 1814 ReturnTyp: types.T_bool, 1815 Fn: operator.LtGeneral[types.Timestamp], 1816 }, 1817 { 1818 Index: 18, 1819 Args: []types.T{ 1820 types.T_blob, 1821 types.T_blob, 1822 }, 1823 ReturnTyp: types.T_bool, 1824 Fn: operator.LtString, 1825 }, 1826 { 1827 Index: 19, 1828 Args: []types.T{ 1829 types.T_uuid, 1830 types.T_uuid, 1831 }, 1832 ReturnTyp: types.T_bool, 1833 Fn: operator.LtUuid, 1834 }, 1835 { 1836 Index: 20, 1837 Args: []types.T{ 1838 types.T_text, 1839 types.T_text, 1840 }, 1841 ReturnTyp: types.T_bool, 1842 Fn: operator.LtString, 1843 }, 1844 { 1845 Index: 21, 1846 Args: []types.T{ 1847 types.T_time, 1848 types.T_time, 1849 }, 1850 ReturnTyp: types.T_bool, 1851 Fn: operator.LtGeneral[types.Time], 1852 }, 1853 }, 1854 }, 1855 1856 LESS_EQUAL: { 1857 Id: LESS_EQUAL, 1858 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 1859 Layout: COMPARISON_OPERATOR, 1860 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 1861 Overloads: []Function{ 1862 { 1863 Index: 0, 1864 Args: []types.T{ 1865 types.T_uint8, 1866 types.T_uint8, 1867 }, 1868 ReturnTyp: types.T_bool, 1869 Fn: operator.LeGeneral[uint8], 1870 }, 1871 { 1872 Index: 1, 1873 Args: []types.T{ 1874 types.T_uint16, 1875 types.T_uint16, 1876 }, 1877 ReturnTyp: types.T_bool, 1878 Fn: operator.LeGeneral[uint16], 1879 }, 1880 { 1881 Index: 2, 1882 Args: []types.T{ 1883 types.T_uint32, 1884 types.T_uint32, 1885 }, 1886 ReturnTyp: types.T_bool, 1887 Fn: operator.LeGeneral[uint32], 1888 }, 1889 { 1890 Index: 3, 1891 Args: []types.T{ 1892 types.T_uint64, 1893 types.T_uint64, 1894 }, 1895 ReturnTyp: types.T_bool, 1896 Fn: operator.LeGeneral[uint64], 1897 }, 1898 { 1899 Index: 4, 1900 Args: []types.T{ 1901 types.T_int8, 1902 types.T_int8, 1903 }, 1904 ReturnTyp: types.T_bool, 1905 Fn: operator.LeGeneral[int8], 1906 }, 1907 { 1908 Index: 5, 1909 Args: []types.T{ 1910 types.T_int16, 1911 types.T_int16, 1912 }, 1913 ReturnTyp: types.T_bool, 1914 Fn: operator.LeGeneral[int16], 1915 }, 1916 { 1917 Index: 6, 1918 Args: []types.T{ 1919 types.T_int32, 1920 types.T_int32, 1921 }, 1922 ReturnTyp: types.T_bool, 1923 Fn: operator.LeGeneral[int32], 1924 }, 1925 { 1926 Index: 7, 1927 Args: []types.T{ 1928 types.T_int64, 1929 types.T_int64, 1930 }, 1931 ReturnTyp: types.T_bool, 1932 Fn: operator.LeGeneral[int64], 1933 }, 1934 { 1935 Index: 8, 1936 Args: []types.T{ 1937 types.T_float32, 1938 types.T_float32, 1939 }, 1940 ReturnTyp: types.T_bool, 1941 Fn: operator.LeGeneral[float32], 1942 }, 1943 { 1944 Index: 9, 1945 Args: []types.T{ 1946 types.T_float64, 1947 types.T_float64, 1948 }, 1949 ReturnTyp: types.T_bool, 1950 Fn: operator.LeGeneral[float64], 1951 }, 1952 { 1953 Index: 10, 1954 Args: []types.T{ 1955 types.T_decimal64, 1956 types.T_decimal64, 1957 }, 1958 ReturnTyp: types.T_bool, 1959 Fn: operator.LeDecimal64, 1960 }, 1961 { 1962 Index: 11, 1963 Args: []types.T{ 1964 types.T_decimal128, 1965 types.T_decimal128, 1966 }, 1967 ReturnTyp: types.T_bool, 1968 Fn: operator.LeDecimal128, 1969 }, 1970 { 1971 Index: 12, 1972 Args: []types.T{ 1973 types.T_varchar, 1974 types.T_varchar, 1975 }, 1976 ReturnTyp: types.T_bool, 1977 Fn: operator.LeString, 1978 }, 1979 { 1980 Index: 13, 1981 Args: []types.T{ 1982 types.T_char, 1983 types.T_char, 1984 }, 1985 ReturnTyp: types.T_bool, 1986 Fn: operator.LeString, 1987 }, 1988 { 1989 Index: 14, 1990 Args: []types.T{ 1991 types.T_date, 1992 types.T_date, 1993 }, 1994 ReturnTyp: types.T_bool, 1995 Fn: operator.LeGeneral[types.Date], 1996 }, 1997 { 1998 Index: 15, 1999 Args: []types.T{ 2000 types.T_datetime, 2001 types.T_datetime, 2002 }, 2003 ReturnTyp: types.T_bool, 2004 Fn: operator.LeGeneral[types.Datetime], 2005 }, 2006 { 2007 Index: 16, 2008 Args: []types.T{ 2009 types.T_bool, 2010 types.T_bool, 2011 }, 2012 ReturnTyp: types.T_bool, 2013 Fn: operator.LeGeneral[bool], 2014 }, 2015 { 2016 Index: 17, 2017 Args: []types.T{ 2018 types.T_timestamp, 2019 types.T_timestamp, 2020 }, 2021 ReturnTyp: types.T_bool, 2022 Fn: operator.LeGeneral[types.Timestamp], 2023 }, 2024 { 2025 Index: 18, 2026 Args: []types.T{ 2027 types.T_blob, 2028 types.T_blob, 2029 }, 2030 ReturnTyp: types.T_bool, 2031 Fn: operator.LeString, 2032 }, 2033 { 2034 Index: 19, 2035 Args: []types.T{ 2036 types.T_uuid, 2037 types.T_uuid, 2038 }, 2039 ReturnTyp: types.T_bool, 2040 Fn: operator.LeUuid, 2041 }, 2042 { 2043 Index: 20, 2044 Args: []types.T{ 2045 types.T_text, 2046 types.T_text, 2047 }, 2048 ReturnTyp: types.T_bool, 2049 Fn: operator.LeString, 2050 }, 2051 { 2052 Index: 21, 2053 Args: []types.T{ 2054 types.T_time, 2055 types.T_time, 2056 }, 2057 ReturnTyp: types.T_bool, 2058 Fn: operator.LeGeneral[types.Time], 2059 }, 2060 }, 2061 }, 2062 2063 NOT_EQUAL: { 2064 Id: NOT_EQUAL, 2065 Flag: plan.Function_STRICT, 2066 Layout: COMPARISON_OPERATOR, 2067 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 2068 Overloads: []Function{ 2069 { 2070 Index: 0, 2071 Args: []types.T{ 2072 types.T_uint8, 2073 types.T_uint8, 2074 }, 2075 ReturnTyp: types.T_bool, 2076 Fn: operator.NeGeneral[uint8], 2077 }, 2078 { 2079 Index: 1, 2080 Args: []types.T{ 2081 types.T_uint16, 2082 types.T_uint16, 2083 }, 2084 ReturnTyp: types.T_bool, 2085 Fn: operator.NeGeneral[uint16], 2086 }, 2087 { 2088 Index: 2, 2089 Args: []types.T{ 2090 types.T_uint32, 2091 types.T_uint32, 2092 }, 2093 ReturnTyp: types.T_bool, 2094 Fn: operator.NeGeneral[uint32], 2095 }, 2096 { 2097 Index: 3, 2098 Args: []types.T{ 2099 types.T_uint64, 2100 types.T_uint64, 2101 }, 2102 ReturnTyp: types.T_bool, 2103 Fn: operator.NeGeneral[uint64], 2104 }, 2105 { 2106 Index: 4, 2107 Args: []types.T{ 2108 types.T_int8, 2109 types.T_int8, 2110 }, 2111 ReturnTyp: types.T_bool, 2112 Fn: operator.NeGeneral[int8], 2113 }, 2114 { 2115 Index: 5, 2116 Args: []types.T{ 2117 types.T_int16, 2118 types.T_int16, 2119 }, 2120 ReturnTyp: types.T_bool, 2121 Fn: operator.NeGeneral[int16], 2122 }, 2123 { 2124 Index: 6, 2125 Args: []types.T{ 2126 types.T_int32, 2127 types.T_int32, 2128 }, 2129 ReturnTyp: types.T_bool, 2130 Fn: operator.NeGeneral[int32], 2131 }, 2132 { 2133 Index: 7, 2134 Args: []types.T{ 2135 types.T_int64, 2136 types.T_int64, 2137 }, 2138 ReturnTyp: types.T_bool, 2139 Fn: operator.NeGeneral[int64], 2140 }, 2141 { 2142 Index: 8, 2143 Args: []types.T{ 2144 types.T_float32, 2145 types.T_float32, 2146 }, 2147 ReturnTyp: types.T_bool, 2148 Fn: operator.NeGeneral[float32], 2149 }, 2150 { 2151 Index: 9, 2152 Args: []types.T{ 2153 types.T_float64, 2154 types.T_float64, 2155 }, 2156 ReturnTyp: types.T_bool, 2157 Fn: operator.NeGeneral[float64], 2158 }, 2159 { 2160 Index: 10, 2161 Args: []types.T{ 2162 types.T_decimal64, 2163 types.T_decimal64, 2164 }, 2165 ReturnTyp: types.T_bool, 2166 Fn: operator.NeDecimal64, 2167 }, 2168 { 2169 Index: 11, 2170 Args: []types.T{ 2171 types.T_decimal128, 2172 types.T_decimal128, 2173 }, 2174 ReturnTyp: types.T_bool, 2175 Fn: operator.NeDecimal128, 2176 }, 2177 { 2178 Index: 12, 2179 Args: []types.T{ 2180 types.T_varchar, 2181 types.T_varchar, 2182 }, 2183 ReturnTyp: types.T_bool, 2184 Fn: operator.NeString, 2185 }, 2186 { 2187 Index: 13, 2188 Args: []types.T{ 2189 types.T_char, 2190 types.T_char, 2191 }, 2192 ReturnTyp: types.T_bool, 2193 Fn: operator.NeString, 2194 }, 2195 { 2196 Index: 14, 2197 Args: []types.T{ 2198 types.T_date, 2199 types.T_date, 2200 }, 2201 ReturnTyp: types.T_bool, 2202 Fn: operator.NeGeneral[types.Date], 2203 }, 2204 { 2205 Index: 15, 2206 Args: []types.T{ 2207 types.T_datetime, 2208 types.T_datetime, 2209 }, 2210 ReturnTyp: types.T_bool, 2211 Fn: operator.NeGeneral[types.Datetime], 2212 }, 2213 { 2214 Index: 16, 2215 Args: []types.T{ 2216 types.T_bool, 2217 types.T_bool, 2218 }, 2219 ReturnTyp: types.T_bool, 2220 Fn: operator.NeGeneral[bool], 2221 }, 2222 { 2223 Index: 17, 2224 Args: []types.T{ 2225 types.T_timestamp, 2226 types.T_timestamp, 2227 }, 2228 ReturnTyp: types.T_bool, 2229 Fn: operator.NeGeneral[types.Timestamp], 2230 }, 2231 { 2232 Index: 18, 2233 Args: []types.T{ 2234 types.T_blob, 2235 types.T_blob, 2236 }, 2237 ReturnTyp: types.T_bool, 2238 Fn: operator.NeString, 2239 }, 2240 { 2241 Index: 19, 2242 Args: []types.T{ 2243 types.T_uuid, 2244 types.T_uuid, 2245 }, 2246 ReturnTyp: types.T_bool, 2247 Fn: operator.NeUuid, 2248 }, 2249 { 2250 Index: 20, 2251 Args: []types.T{ 2252 types.T_text, 2253 types.T_text, 2254 }, 2255 ReturnTyp: types.T_bool, 2256 Fn: operator.NeString, 2257 }, 2258 { 2259 Index: 21, 2260 Args: []types.T{ 2261 types.T_time, 2262 types.T_time, 2263 }, 2264 ReturnTyp: types.T_bool, 2265 Fn: operator.NeGeneral[types.Time], 2266 }, 2267 }, 2268 }, 2269 2270 LIKE: { 2271 Id: LIKE, 2272 Flag: plan.Function_STRICT, 2273 Layout: BINARY_LOGICAL_OPERATOR, 2274 Overloads: []Function{ 2275 { 2276 Index: 0, 2277 Args: []types.T{ 2278 types.T_char, 2279 types.T_char, 2280 }, 2281 ReturnTyp: types.T_bool, 2282 Fn: operator.Like, 2283 }, 2284 { 2285 Index: 1, 2286 Args: []types.T{ 2287 types.T_varchar, 2288 types.T_varchar, 2289 }, 2290 ReturnTyp: types.T_bool, 2291 Fn: operator.Like, 2292 }, 2293 { 2294 Index: 2, 2295 Args: []types.T{ 2296 types.T_text, 2297 types.T_text, 2298 }, 2299 ReturnTyp: types.T_bool, 2300 Fn: operator.Like, 2301 }, 2302 }, 2303 }, 2304 2305 ILIKE: { 2306 Id: ILIKE, 2307 Flag: plan.Function_STRICT, 2308 Layout: BINARY_LOGICAL_OPERATOR, 2309 Overloads: []Function{ 2310 { 2311 Index: 0, 2312 Args: []types.T{ 2313 types.T_char, 2314 types.T_char, 2315 }, 2316 ReturnTyp: types.T_bool, 2317 Fn: operator.ILike, 2318 }, 2319 { 2320 Index: 1, 2321 Args: []types.T{ 2322 types.T_varchar, 2323 types.T_varchar, 2324 }, 2325 ReturnTyp: types.T_bool, 2326 Fn: operator.ILike, 2327 }, 2328 { 2329 Index: 2, 2330 Args: []types.T{ 2331 types.T_text, 2332 types.T_text, 2333 }, 2334 ReturnTyp: types.T_bool, 2335 Fn: operator.ILike, 2336 }, 2337 }, 2338 }, 2339 2340 BETWEEN: { 2341 Id: BETWEEN, 2342 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 2343 Layout: BETWEEN_AND_EXPRESSION, 2344 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 2345 Overloads: []Function{ 2346 { 2347 Index: 0, 2348 Args: []types.T{ 2349 types.T_uint8, 2350 types.T_uint8, 2351 }, 2352 ReturnTyp: types.T_bool, 2353 Fn: nil, 2354 }, 2355 { 2356 Index: 1, 2357 Args: []types.T{ 2358 types.T_uint16, 2359 types.T_uint16, 2360 }, 2361 ReturnTyp: types.T_bool, 2362 Fn: nil, 2363 }, 2364 { 2365 Index: 2, 2366 Args: []types.T{ 2367 types.T_uint32, 2368 types.T_uint32, 2369 }, 2370 ReturnTyp: types.T_bool, 2371 Fn: nil, 2372 }, 2373 { 2374 Index: 3, 2375 Args: []types.T{ 2376 types.T_uint64, 2377 types.T_uint64, 2378 }, 2379 ReturnTyp: types.T_bool, 2380 Fn: nil, 2381 }, 2382 { 2383 Index: 4, 2384 Args: []types.T{ 2385 types.T_int8, 2386 types.T_int8, 2387 }, 2388 ReturnTyp: types.T_bool, 2389 Fn: nil, 2390 }, 2391 { 2392 Index: 5, 2393 Args: []types.T{ 2394 types.T_int16, 2395 types.T_int16, 2396 }, 2397 ReturnTyp: types.T_bool, 2398 Fn: nil, 2399 }, 2400 { 2401 Index: 6, 2402 Args: []types.T{ 2403 types.T_int32, 2404 types.T_int32, 2405 }, 2406 ReturnTyp: types.T_bool, 2407 Fn: nil, 2408 }, 2409 { 2410 Index: 7, 2411 Args: []types.T{ 2412 types.T_int64, 2413 types.T_int64, 2414 }, 2415 ReturnTyp: types.T_bool, 2416 Fn: nil, 2417 }, 2418 { 2419 Index: 8, 2420 Args: []types.T{ 2421 types.T_float32, 2422 types.T_float32, 2423 }, 2424 ReturnTyp: types.T_bool, 2425 Fn: nil, 2426 }, 2427 { 2428 Index: 9, 2429 Args: []types.T{ 2430 types.T_float64, 2431 types.T_float64, 2432 }, 2433 ReturnTyp: types.T_bool, 2434 Fn: nil, 2435 }, 2436 { 2437 Index: 10, 2438 Args: []types.T{ 2439 types.T_decimal64, 2440 types.T_decimal64, 2441 }, 2442 ReturnTyp: types.T_bool, 2443 Fn: nil, 2444 }, 2445 { 2446 Index: 11, 2447 Args: []types.T{ 2448 types.T_decimal128, 2449 types.T_decimal128, 2450 }, 2451 ReturnTyp: types.T_bool, 2452 Fn: nil, 2453 }, 2454 }, 2455 }, 2456 2457 EXISTS: { 2458 Id: EXISTS, 2459 Flag: plan.Function_STRICT, 2460 Layout: EXISTS_ANY_PREDICATE, 2461 TypeCheckFn: func(_ []Function, inputs []types.T) (overloadIndex int32, _ []types.T) { 2462 if len(inputs) == 1 { 2463 return 0, nil 2464 } 2465 return wrongFunctionParameters, nil 2466 }, 2467 Overloads: []Function{ 2468 { 2469 Index: 0, 2470 ReturnTyp: types.T_bool, 2471 }, 2472 }, 2473 }, 2474 2475 // logic operator 2476 AND: { 2477 Id: AND, 2478 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 2479 Layout: BINARY_LOGICAL_OPERATOR, 2480 Overloads: []Function{ 2481 { 2482 Index: 0, 2483 Args: []types.T{ 2484 types.T_bool, 2485 types.T_bool, 2486 }, 2487 ReturnTyp: types.T_bool, 2488 Fn: operator.LogicAnd, 2489 }, 2490 }, 2491 }, 2492 2493 OR: { 2494 Id: OR, 2495 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 2496 Layout: BINARY_LOGICAL_OPERATOR, 2497 Overloads: []Function{ 2498 { 2499 Index: 0, 2500 Args: []types.T{ 2501 types.T_bool, 2502 types.T_bool, 2503 }, 2504 ReturnTyp: types.T_bool, 2505 Fn: operator.LogicOr, 2506 }, 2507 }, 2508 }, 2509 2510 XOR: { 2511 Id: XOR, 2512 Flag: plan.Function_STRICT, 2513 Layout: BINARY_LOGICAL_OPERATOR, 2514 Overloads: []Function{ 2515 { 2516 Index: 0, 2517 Args: []types.T{ 2518 types.T_bool, 2519 types.T_bool, 2520 }, 2521 ReturnTyp: types.T_bool, 2522 Fn: operator.LogicXor, 2523 }, 2524 }, 2525 }, 2526 2527 NOT: { 2528 Id: NOT, 2529 Flag: plan.Function_STRICT, 2530 Layout: UNARY_LOGICAL_OPERATOR, 2531 Overloads: []Function{ 2532 { 2533 Index: 0, 2534 Args: []types.T{ 2535 types.T_bool, 2536 }, 2537 ReturnTyp: types.T_bool, 2538 Fn: operator.LogicNot, 2539 }, 2540 }, 2541 }, 2542 2543 // arithmetic operator 2544 PLUS: { 2545 Id: PLUS, 2546 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 2547 Layout: BINARY_ARITHMETIC_OPERATOR, 2548 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 2549 Overloads: []Function{ 2550 { 2551 Index: 0, 2552 Args: []types.T{types.T_uint8, types.T_uint8}, 2553 ReturnTyp: types.T_uint8, 2554 Fn: operator.PlusUint[uint8], 2555 }, 2556 { 2557 Index: 1, 2558 Args: []types.T{types.T_uint16, types.T_uint16}, 2559 ReturnTyp: types.T_uint16, 2560 Fn: operator.PlusUint[uint16], 2561 }, 2562 { 2563 Index: 2, 2564 Args: []types.T{types.T_uint32, types.T_uint32}, 2565 ReturnTyp: types.T_uint32, 2566 Fn: operator.PlusUint[uint32], 2567 }, 2568 { 2569 Index: 3, 2570 Args: []types.T{types.T_uint64, types.T_uint64}, 2571 ReturnTyp: types.T_uint64, 2572 Fn: operator.PlusUint[uint64], 2573 }, 2574 { 2575 Index: 4, 2576 Args: []types.T{types.T_int8, types.T_int8}, 2577 ReturnTyp: types.T_int8, 2578 Fn: operator.PlusInt[int8], 2579 }, 2580 { 2581 Index: 5, 2582 Args: []types.T{types.T_int16, types.T_int16}, 2583 ReturnTyp: types.T_int16, 2584 Fn: operator.PlusInt[int16], 2585 }, 2586 { 2587 Index: 6, 2588 Args: []types.T{types.T_int32, types.T_int32}, 2589 ReturnTyp: types.T_int32, 2590 Fn: operator.PlusInt[int32], 2591 }, 2592 { 2593 Index: 7, 2594 Args: []types.T{types.T_int64, types.T_int64}, 2595 ReturnTyp: types.T_int64, 2596 Fn: operator.PlusInt[int64], 2597 }, 2598 { 2599 Index: 8, 2600 Args: []types.T{types.T_float32, types.T_float32}, 2601 ReturnTyp: types.T_float32, 2602 Fn: operator.PlusFloat[float32], 2603 }, 2604 { 2605 Index: 9, 2606 Args: []types.T{types.T_float64, types.T_float64}, 2607 ReturnTyp: types.T_float64, 2608 Fn: operator.PlusFloat[float64], 2609 }, 2610 { 2611 Index: 10, 2612 Args: []types.T{types.T_decimal64, types.T_decimal64}, 2613 ReturnTyp: types.T_decimal64, 2614 Fn: operator.PlusDecimal64, 2615 }, 2616 { 2617 Index: 11, 2618 Args: []types.T{types.T_decimal128, types.T_decimal128}, 2619 ReturnTyp: types.T_decimal128, 2620 Fn: operator.PlusDecimal128, 2621 }, 2622 { 2623 Index: 12, 2624 Args: []types.T{types.T_date, types.T_interval}, 2625 ReturnTyp: types.T_date, 2626 Fn: nil, 2627 }, 2628 }, 2629 }, 2630 2631 MINUS: { 2632 Id: MINUS, 2633 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 2634 Layout: BINARY_ARITHMETIC_OPERATOR, 2635 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 2636 Overloads: []Function{ 2637 { 2638 Index: 0, 2639 Args: []types.T{types.T_uint8, types.T_uint8}, 2640 ReturnTyp: types.T_uint8, 2641 Fn: operator.MinusUint[uint8], 2642 }, 2643 { 2644 Index: 1, 2645 Args: []types.T{types.T_uint16, types.T_uint16}, 2646 ReturnTyp: types.T_uint16, 2647 Fn: operator.MinusUint[uint16], 2648 }, 2649 { 2650 Index: 2, 2651 Args: []types.T{types.T_uint32, types.T_uint32}, 2652 ReturnTyp: types.T_uint32, 2653 Fn: operator.MinusUint[uint32], 2654 }, 2655 { 2656 Index: 3, 2657 Args: []types.T{types.T_uint64, types.T_uint64}, 2658 ReturnTyp: types.T_uint64, 2659 Fn: operator.MinusUint[uint64], 2660 }, 2661 { 2662 Index: 4, 2663 Args: []types.T{types.T_int8, types.T_int8}, 2664 ReturnTyp: types.T_int8, 2665 Fn: operator.MinusInt[int8], 2666 }, 2667 { 2668 Index: 5, 2669 Args: []types.T{types.T_int16, types.T_int16}, 2670 ReturnTyp: types.T_int16, 2671 Fn: operator.MinusInt[int16], 2672 }, 2673 { 2674 Index: 6, 2675 Args: []types.T{types.T_int32, types.T_int32}, 2676 ReturnTyp: types.T_int32, 2677 Fn: operator.MinusInt[int32], 2678 }, 2679 { 2680 Index: 7, 2681 Args: []types.T{types.T_int64, types.T_int64}, 2682 ReturnTyp: types.T_int64, 2683 Fn: operator.MinusInt[int64], 2684 }, 2685 { 2686 Index: 8, 2687 Args: []types.T{types.T_float32, types.T_float32}, 2688 ReturnTyp: types.T_float32, 2689 Fn: operator.MinusFloat[float32], 2690 }, 2691 { 2692 Index: 9, 2693 Args: []types.T{types.T_float64, types.T_float64}, 2694 ReturnTyp: types.T_float64, 2695 Fn: operator.MinusFloat[float64], 2696 }, 2697 { 2698 Index: 10, 2699 Args: []types.T{types.T_decimal64, types.T_decimal64}, 2700 ReturnTyp: types.T_decimal64, 2701 Fn: operator.MinusDecimal64, 2702 }, 2703 { 2704 Index: 11, 2705 Args: []types.T{types.T_decimal128, types.T_decimal128}, 2706 ReturnTyp: types.T_decimal128, 2707 Fn: operator.MinusDecimal128, 2708 }, 2709 { 2710 Index: 12, 2711 Args: []types.T{types.T_date, types.T_date}, 2712 ReturnTyp: types.T_int64, 2713 Fn: binary.DateDiff, 2714 }, 2715 { 2716 Index: 13, 2717 Args: []types.T{types.T_datetime, types.T_datetime}, 2718 ReturnTyp: types.T_int64, 2719 Fn: operator.MinusDatetime, 2720 }, 2721 }, 2722 }, 2723 2724 MULTI: { 2725 Id: MULTI, 2726 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 2727 Layout: BINARY_ARITHMETIC_OPERATOR, 2728 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 2729 Overloads: []Function{ 2730 { 2731 Index: 0, 2732 Args: []types.T{types.T_uint8, types.T_uint8}, 2733 ReturnTyp: types.T_uint8, 2734 Fn: operator.MultUint[uint8], 2735 }, 2736 { 2737 Index: 1, 2738 Args: []types.T{types.T_uint16, types.T_uint16}, 2739 ReturnTyp: types.T_uint16, 2740 Fn: operator.MultUint[uint16], 2741 }, 2742 { 2743 Index: 2, 2744 Args: []types.T{types.T_uint32, types.T_uint32}, 2745 ReturnTyp: types.T_uint32, 2746 Fn: operator.MultUint[uint32], 2747 }, 2748 { 2749 Index: 3, 2750 Args: []types.T{types.T_uint64, types.T_uint64}, 2751 ReturnTyp: types.T_uint64, 2752 Fn: operator.MultUint[uint64], 2753 }, 2754 { 2755 Index: 4, 2756 Args: []types.T{types.T_int8, types.T_int8}, 2757 ReturnTyp: types.T_int8, 2758 Fn: operator.MultInt[int8], 2759 }, 2760 { 2761 Index: 5, 2762 Args: []types.T{types.T_int16, types.T_int16}, 2763 ReturnTyp: types.T_int16, 2764 Fn: operator.MultInt[int16], 2765 }, 2766 { 2767 Index: 6, 2768 Args: []types.T{types.T_int32, types.T_int32}, 2769 ReturnTyp: types.T_int32, 2770 Fn: operator.MultInt[int32], 2771 }, 2772 { 2773 Index: 7, 2774 Args: []types.T{types.T_int64, types.T_int64}, 2775 ReturnTyp: types.T_int64, 2776 Fn: operator.MultInt[int64], 2777 }, 2778 { 2779 Index: 8, 2780 Args: []types.T{types.T_float32, types.T_float32}, 2781 ReturnTyp: types.T_float32, 2782 Fn: operator.MultFloat[float32], 2783 }, 2784 { 2785 Index: 9, 2786 Args: []types.T{types.T_float64, types.T_float64}, 2787 ReturnTyp: types.T_float64, 2788 Fn: operator.MultFloat[float64], 2789 }, 2790 { 2791 Index: 10, 2792 Args: []types.T{types.T_decimal64, types.T_decimal64}, 2793 ReturnTyp: types.T_decimal128, 2794 Fn: operator.MultDecimal64, 2795 }, 2796 { 2797 Index: 11, 2798 Args: []types.T{types.T_decimal128, types.T_decimal128}, 2799 ReturnTyp: types.T_decimal128, 2800 Fn: operator.MultDecimal128, 2801 }, 2802 }, 2803 }, 2804 2805 DIV: { 2806 Id: DIV, 2807 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 2808 Layout: BINARY_ARITHMETIC_OPERATOR, 2809 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn2, 2810 Overloads: []Function{ 2811 { 2812 Index: 0, 2813 Args: []types.T{types.T_float32, types.T_float32}, 2814 ReturnTyp: types.T_float32, 2815 Fn: operator.DivFloat[float32], 2816 }, 2817 { 2818 Index: 1, 2819 Args: []types.T{types.T_float64, types.T_float64}, 2820 ReturnTyp: types.T_float64, 2821 Fn: operator.DivFloat[float64], 2822 }, 2823 { 2824 Index: 2, 2825 Args: []types.T{types.T_decimal64, types.T_decimal64}, 2826 ReturnTyp: types.T_decimal128, 2827 Fn: operator.DivDecimal64, 2828 }, 2829 { 2830 Index: 3, 2831 Args: []types.T{types.T_decimal128, types.T_decimal128}, 2832 ReturnTyp: types.T_decimal128, 2833 Fn: operator.DivDecimal128, 2834 }, 2835 }, 2836 }, 2837 2838 INTEGER_DIV: { 2839 Id: INTEGER_DIV, 2840 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 2841 Layout: BINARY_ARITHMETIC_OPERATOR, 2842 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn2, 2843 Overloads: []Function{ 2844 { 2845 Index: 0, 2846 Args: []types.T{types.T_float32, types.T_float32}, 2847 ReturnTyp: types.T_int64, 2848 Fn: operator.IntegerDivFloat[float32], 2849 }, 2850 { 2851 Index: 1, 2852 Args: []types.T{types.T_float64, types.T_float64}, 2853 ReturnTyp: types.T_int64, 2854 Fn: operator.IntegerDivFloat[float64], 2855 }, 2856 }, 2857 }, 2858 2859 MOD: { 2860 Id: MOD, 2861 Flag: plan.Function_STRICT, 2862 Layout: BINARY_ARITHMETIC_OPERATOR, 2863 TypeCheckFn: GeneralBinaryOperatorTypeCheckFn1, 2864 Overloads: []Function{ 2865 { 2866 Index: 0, 2867 Args: []types.T{types.T_uint8, types.T_uint8}, 2868 ReturnTyp: types.T_uint8, 2869 Fn: operator.ModUint[uint8], 2870 }, 2871 { 2872 Index: 1, 2873 Args: []types.T{types.T_uint16, types.T_uint16}, 2874 ReturnTyp: types.T_uint16, 2875 Fn: operator.ModUint[uint16], 2876 }, 2877 { 2878 Index: 2, 2879 Args: []types.T{types.T_uint32, types.T_uint32}, 2880 ReturnTyp: types.T_uint32, 2881 Fn: operator.ModUint[uint32], 2882 }, 2883 { 2884 Index: 3, 2885 Args: []types.T{types.T_uint64, types.T_uint64}, 2886 ReturnTyp: types.T_uint64, 2887 Fn: operator.ModUint[uint64], 2888 }, 2889 { 2890 Index: 4, 2891 Args: []types.T{types.T_int8, types.T_int8}, 2892 ReturnTyp: types.T_int8, 2893 Fn: operator.ModInt[int8], 2894 }, 2895 { 2896 Index: 5, 2897 Args: []types.T{types.T_int16, types.T_int16}, 2898 ReturnTyp: types.T_int16, 2899 Fn: operator.ModInt[int16], 2900 }, 2901 { 2902 Index: 6, 2903 Args: []types.T{types.T_int32, types.T_int32}, 2904 ReturnTyp: types.T_int32, 2905 Fn: operator.ModInt[int32], 2906 }, 2907 { 2908 Index: 7, 2909 Args: []types.T{types.T_int64, types.T_int64}, 2910 ReturnTyp: types.T_int64, 2911 Fn: operator.ModInt[int64], 2912 }, 2913 { 2914 Index: 8, 2915 Args: []types.T{types.T_float32, types.T_float32}, 2916 ReturnTyp: types.T_float32, 2917 Fn: operator.ModFloat[float32], 2918 }, 2919 { 2920 Index: 9, 2921 Args: []types.T{types.T_float64, types.T_float64}, 2922 ReturnTyp: types.T_float64, 2923 Fn: operator.ModFloat[float64], 2924 }, 2925 }, 2926 }, 2927 2928 UNARY_PLUS: { 2929 Id: UNARY_PLUS, 2930 Flag: plan.Function_STRICT | plan.Function_MONOTONIC, 2931 Layout: UNARY_ARITHMETIC_OPERATOR, 2932 Overloads: []Function{ 2933 { 2934 Index: 0, 2935 Args: []types.T{types.T_uint8}, 2936 ReturnTyp: types.T_uint8, 2937 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 2938 data := vs[0].Col.([]uint8) 2939 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 2940 return vec, nil 2941 }, 2942 }, 2943 { 2944 Index: 1, 2945 Args: []types.T{types.T_uint16}, 2946 ReturnTyp: types.T_uint16, 2947 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 2948 data := vs[0].Col.([]uint16) 2949 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 2950 return vec, nil 2951 }, 2952 }, 2953 { 2954 Index: 2, 2955 Args: []types.T{types.T_uint32}, 2956 ReturnTyp: types.T_uint32, 2957 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 2958 data := vs[0].Col.([]uint32) 2959 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 2960 return vec, nil 2961 }, 2962 }, 2963 { 2964 Index: 3, 2965 Args: []types.T{types.T_uint64}, 2966 ReturnTyp: types.T_uint64, 2967 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 2968 data := vs[0].Col.([]uint64) 2969 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 2970 return vec, nil 2971 }, 2972 }, 2973 { 2974 Index: 4, 2975 Args: []types.T{types.T_int8}, 2976 ReturnTyp: types.T_int8, 2977 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 2978 data := vs[0].Col.([]int8) 2979 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 2980 return vec, nil 2981 }, 2982 }, 2983 { 2984 Index: 5, 2985 Args: []types.T{types.T_int16}, 2986 ReturnTyp: types.T_int16, 2987 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 2988 data := vs[0].Col.([]int16) 2989 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 2990 return vec, nil 2991 }, 2992 }, 2993 { 2994 Index: 6, 2995 Args: []types.T{types.T_int32}, 2996 ReturnTyp: types.T_int32, 2997 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 2998 data := vs[0].Col.([]int32) 2999 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 3000 return vec, nil 3001 }, 3002 }, 3003 { 3004 Index: 7, 3005 Args: []types.T{types.T_int64}, 3006 ReturnTyp: types.T_int64, 3007 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 3008 data := vs[0].Col.([]int64) 3009 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 3010 return vec, nil 3011 }, 3012 }, 3013 { 3014 Index: 8, 3015 Args: []types.T{types.T_float32}, 3016 ReturnTyp: types.T_float32, 3017 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 3018 data := vs[0].Col.([]float32) 3019 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 3020 return vec, nil 3021 }, 3022 }, 3023 { 3024 Index: 9, 3025 Args: []types.T{types.T_float64}, 3026 ReturnTyp: types.T_float64, 3027 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 3028 data := vs[0].Col.([]float64) 3029 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 3030 return vec, nil 3031 }, 3032 }, 3033 { 3034 Index: 10, 3035 Args: []types.T{types.T_decimal64}, 3036 ReturnTyp: types.T_decimal64, 3037 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 3038 data := vs[0].Col.([]types.Decimal64) 3039 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 3040 return vec, nil 3041 }, 3042 }, 3043 { 3044 Index: 11, 3045 Args: []types.T{types.T_decimal128}, 3046 ReturnTyp: types.T_decimal128, 3047 Fn: func(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error) { 3048 data := vs[0].Col.([]types.Decimal128) 3049 vec := vector.NewConstFixed(vs[0].Typ, vs[0].Length(), data[0], proc.Mp()) 3050 return vec, nil 3051 }, 3052 }, 3053 }, 3054 }, 3055 3056 UNARY_MINUS: { 3057 Id: UNARY_MINUS, 3058 Flag: plan.Function_STRICT, 3059 Layout: UNARY_ARITHMETIC_OPERATOR, 3060 Overloads: []Function{ 3061 { 3062 Index: 0, 3063 Args: []types.T{types.T_int8}, 3064 ReturnTyp: types.T_int8, 3065 Fn: operator.UnaryMinus[int8], 3066 }, 3067 { 3068 Index: 1, 3069 Args: []types.T{types.T_int16}, 3070 ReturnTyp: types.T_int16, 3071 Fn: operator.UnaryMinus[int16], 3072 }, 3073 { 3074 Index: 2, 3075 Args: []types.T{types.T_int32}, 3076 ReturnTyp: types.T_int32, 3077 Fn: operator.UnaryMinus[int32], 3078 }, 3079 { 3080 Index: 3, 3081 Args: []types.T{types.T_int64}, 3082 ReturnTyp: types.T_int64, 3083 Fn: operator.UnaryMinus[int64], 3084 }, 3085 { 3086 Index: 4, 3087 Args: []types.T{types.T_float32}, 3088 ReturnTyp: types.T_float32, 3089 Fn: operator.UnaryMinus[float32], 3090 }, 3091 { 3092 Index: 5, 3093 Args: []types.T{types.T_float64}, 3094 ReturnTyp: types.T_float64, 3095 Fn: operator.UnaryMinus[float64], 3096 }, 3097 { 3098 Index: 6, 3099 Args: []types.T{types.T_decimal64}, 3100 ReturnTyp: types.T_decimal64, 3101 Fn: operator.UnaryMinusDecimal64, 3102 }, 3103 { 3104 Index: 7, 3105 Args: []types.T{types.T_decimal128}, 3106 ReturnTyp: types.T_decimal128, 3107 Fn: operator.UnaryMinusDecimal128, 3108 }, 3109 }, 3110 }, 3111 3112 UNARY_TILDE: { 3113 Id: UNARY_TILDE, 3114 Flag: plan.Function_STRICT, 3115 Layout: UNARY_ARITHMETIC_OPERATOR, 3116 Overloads: []Function{ 3117 { 3118 Index: 0, 3119 Args: []types.T{types.T_int8}, 3120 ReturnTyp: types.T_uint64, 3121 Fn: operator.UnaryTilde[int8], 3122 }, 3123 { 3124 Index: 1, 3125 Args: []types.T{types.T_int16}, 3126 ReturnTyp: types.T_uint64, 3127 Fn: operator.UnaryTilde[int16], 3128 }, 3129 { 3130 Index: 2, 3131 Args: []types.T{types.T_int32}, 3132 ReturnTyp: types.T_uint64, 3133 Fn: operator.UnaryTilde[int32], 3134 }, 3135 { 3136 Index: 3, 3137 Args: []types.T{types.T_int64}, 3138 ReturnTyp: types.T_uint64, 3139 Fn: operator.UnaryTilde[int64], 3140 }, 3141 { 3142 Index: 4, 3143 Args: []types.T{types.T_uint8}, 3144 ReturnTyp: types.T_uint64, 3145 Fn: operator.UnaryTilde[uint8], 3146 }, 3147 { 3148 Index: 5, 3149 Args: []types.T{types.T_uint16}, 3150 ReturnTyp: types.T_uint64, 3151 Fn: operator.UnaryTilde[uint16], 3152 }, 3153 { 3154 Index: 6, 3155 Args: []types.T{types.T_uint32}, 3156 ReturnTyp: types.T_uint64, 3157 Fn: operator.UnaryTilde[uint32], 3158 }, 3159 { 3160 Index: 7, 3161 Args: []types.T{types.T_uint64}, 3162 ReturnTyp: types.T_uint64, 3163 Fn: operator.UnaryTilde[uint64], 3164 }, 3165 }, 3166 }, 3167 3168 // others 3169 CAST: { 3170 Id: CAST, 3171 Flag: plan.Function_STRICT, 3172 Layout: CAST_EXPRESSION, 3173 TypeCheckFn: func(overloads []Function, inputs []types.T) (overloadIndex int32, _ []types.T) { 3174 // cast-operator should check param types strictly 3175 if len(inputs) == 2 { 3176 if operator.IfTypeCastSupported(inputs[0], inputs[1]) { 3177 return 0, nil 3178 } 3179 } 3180 return wrongFunctionParameters, nil 3181 }, 3182 Overloads: []Function{ 3183 { 3184 Index: 0, 3185 UseNewFramework: true, 3186 FlexibleReturnType: func(parameters []types.Type) types.Type { 3187 return parameters[1] 3188 }, 3189 NewFn: operator.NewCast, 3190 }, 3191 }, 3192 }, 3193 3194 COALESCE: { 3195 Id: COALESCE, 3196 Flag: plan.Function_NONE, 3197 Layout: STANDARD_FUNCTION, 3198 TypeCheckFn: func(overloads []Function, inputs []types.T) (overloadIndex int32, ts []types.T) { 3199 l := len(inputs) 3200 if l == 0 { 3201 return wrongFunctionParameters, nil 3202 } 3203 3204 for i, o := range overloads { 3205 if operator.CoalesceTypeCheckFn(inputs, nil, o.ReturnTyp) { 3206 return int32(i), nil 3207 } 3208 } 3209 3210 minCost, minIndex := math.MaxInt32, -1 3211 convertTypes := make([]types.T, l) 3212 targetTypes := make([]types.T, l) 3213 3214 for i, o := range overloads { 3215 for j := 0; j < l; j++ { 3216 targetTypes[j] = o.ReturnTyp 3217 } 3218 if code, c := tryToMatch(inputs, targetTypes); code == matchedByConvert { 3219 if c < minCost { 3220 minCost = c 3221 copy(convertTypes, targetTypes) 3222 minIndex = i 3223 } 3224 } 3225 } 3226 if minIndex != -1 { 3227 return int32(minIndex), convertTypes 3228 } 3229 return wrongFunctionParameters, nil 3230 }, 3231 Overloads: []Function{ 3232 { 3233 Index: 0, 3234 Volatile: true, 3235 ReturnTyp: types.T_varchar, 3236 Fn: operator.CoalesceVarchar, 3237 }, 3238 { 3239 Index: 1, 3240 Volatile: true, 3241 ReturnTyp: types.T_char, 3242 Fn: operator.CoalesceChar, 3243 }, 3244 { 3245 Index: 2, 3246 Volatile: true, 3247 ReturnTyp: types.T_int8, 3248 Fn: operator.CoalesceInt8, 3249 }, 3250 { 3251 Index: 3, 3252 Volatile: true, 3253 ReturnTyp: types.T_int16, 3254 Fn: operator.CoalesceInt16, 3255 }, 3256 { 3257 Index: 4, 3258 Volatile: true, 3259 ReturnTyp: types.T_int32, 3260 Fn: operator.CoalesceInt32, 3261 }, 3262 { 3263 Index: 5, 3264 Volatile: true, 3265 ReturnTyp: types.T_int64, 3266 Fn: operator.CoalesceInt64, 3267 }, 3268 { 3269 Index: 6, 3270 Volatile: true, 3271 ReturnTyp: types.T_uint8, 3272 Fn: operator.CoalesceUint8, 3273 }, 3274 { 3275 Index: 7, 3276 Volatile: true, 3277 ReturnTyp: types.T_uint16, 3278 Fn: operator.CoalesceUint16, 3279 }, 3280 { 3281 Index: 8, 3282 Volatile: true, 3283 ReturnTyp: types.T_uint32, 3284 Fn: operator.CoalesceUint32, 3285 }, 3286 { 3287 Index: 9, 3288 Volatile: true, 3289 ReturnTyp: types.T_uint64, 3290 Fn: operator.CoalesceUint64, 3291 }, 3292 { 3293 Index: 10, 3294 Volatile: true, 3295 ReturnTyp: types.T_float32, 3296 Fn: operator.CoalesceFloat32, 3297 }, 3298 { 3299 Index: 11, 3300 Volatile: true, 3301 ReturnTyp: types.T_float64, 3302 Fn: operator.CoalesceFloat64, 3303 }, 3304 { 3305 Index: 12, 3306 Volatile: true, 3307 ReturnTyp: types.T_bool, 3308 Fn: operator.CoalesceBool, 3309 }, 3310 { 3311 Index: 13, 3312 Volatile: true, 3313 ReturnTyp: types.T_datetime, 3314 Fn: operator.CoalesceDateTime, 3315 }, 3316 { 3317 Index: 14, 3318 Volatile: true, 3319 ReturnTyp: types.T_timestamp, 3320 Fn: operator.CoalesceTimestamp, 3321 }, 3322 { 3323 Index: 15, 3324 Volatile: true, 3325 ReturnTyp: types.T_decimal64, 3326 Fn: operator.CoalesceDecimal64, 3327 }, 3328 { 3329 Index: 16, 3330 Volatile: true, 3331 ReturnTyp: types.T_decimal128, 3332 Fn: operator.CoalesceDecimal128, 3333 }, 3334 { 3335 Index: 17, 3336 Volatile: true, 3337 ReturnTyp: types.T_date, 3338 Fn: operator.CoalesceDate, 3339 }, 3340 { 3341 Index: 18, 3342 Volatile: true, 3343 ReturnTyp: types.T_uuid, 3344 Fn: operator.CoalesceUuid, 3345 }, 3346 { 3347 Index: 19, 3348 Volatile: true, 3349 ReturnTyp: types.T_time, 3350 Fn: operator.CoalesceTime, 3351 }, 3352 { 3353 Index: 20, 3354 Volatile: true, 3355 ReturnTyp: types.T_json, 3356 Fn: operator.CoalesceJson, 3357 }, 3358 { 3359 Index: 21, 3360 Volatile: true, 3361 ReturnTyp: types.T_blob, 3362 Fn: operator.CoalesceBlob, 3363 }, 3364 { 3365 Index: 22, 3366 Volatile: true, 3367 ReturnTyp: types.T_text, 3368 Fn: operator.CoalesceText, 3369 }, 3370 }, 3371 }, 3372 3373 CASE: { 3374 Id: CASE, 3375 Flag: plan.Function_NONE, 3376 Layout: CASE_WHEN_EXPRESSION, 3377 TypeCheckFn: func(overloads []Function, inputs []types.T) (overloadIndex int32, ts []types.T) { 3378 for i, o := range overloads { 3379 if operator.CwTypeCheckFn(inputs, nil, o.ReturnTyp) { 3380 return int32(i), nil 3381 } 3382 } 3383 l := len(inputs) 3384 minCost, minIndex := math.MaxInt32, -1 3385 convertTypes := make([]types.T, l) 3386 targetTypes := make([]types.T, l) 3387 for i, o := range overloads { 3388 if l >= 2 { 3389 flag := true 3390 for j := 0; j < l-1; j += 2 { 3391 if inputs[j] != types.T_bool && !inputs[0].ToType().IsIntOrUint() { 3392 flag = false 3393 break 3394 } 3395 targetTypes[j] = types.T_bool 3396 } 3397 if l%2 == 1 { 3398 targetTypes[l-1] = o.ReturnTyp 3399 } 3400 for j := 1; j < l; j += 2 { 3401 targetTypes[j] = o.ReturnTyp 3402 } 3403 if flag { 3404 if code, c := tryToMatch(inputs, targetTypes); code == matchedByConvert { 3405 if c < minCost { 3406 minCost = c 3407 copy(convertTypes, targetTypes) 3408 minIndex = i 3409 } 3410 } 3411 } 3412 } 3413 } 3414 if minIndex != -1 { 3415 return int32(minIndex), convertTypes 3416 } 3417 return wrongFunctionParameters, nil 3418 }, 3419 Overloads: []Function{ 3420 { 3421 Index: 0, 3422 Volatile: true, 3423 ReturnTyp: types.T_int8, 3424 Fn: operator.CaseWhenInt8, 3425 }, 3426 { 3427 Index: 1, 3428 Volatile: true, 3429 ReturnTyp: types.T_int16, 3430 Fn: operator.CaseWhenInt16, 3431 }, 3432 { 3433 Index: 2, 3434 Volatile: true, 3435 ReturnTyp: types.T_int32, 3436 Fn: operator.CaseWhenInt32, 3437 }, 3438 { 3439 Index: 3, 3440 Volatile: true, 3441 ReturnTyp: types.T_int64, 3442 Fn: operator.CaseWhenInt64, 3443 }, 3444 { 3445 Index: 4, 3446 Volatile: true, 3447 ReturnTyp: types.T_uint8, 3448 Fn: operator.CaseWhenUint8, 3449 }, 3450 { 3451 Index: 5, 3452 Volatile: true, 3453 ReturnTyp: types.T_uint16, 3454 Fn: operator.CaseWhenUint16, 3455 }, 3456 { 3457 Index: 6, 3458 Volatile: true, 3459 ReturnTyp: types.T_uint32, 3460 Fn: operator.CaseWhenUint32, 3461 }, 3462 { 3463 Index: 7, 3464 Volatile: true, 3465 ReturnTyp: types.T_uint64, 3466 Fn: operator.CaseWhenUint64, 3467 }, 3468 { 3469 Index: 8, 3470 Volatile: true, 3471 ReturnTyp: types.T_float32, 3472 Fn: operator.CaseWhenFloat32, 3473 }, 3474 { 3475 Index: 9, 3476 Volatile: true, 3477 ReturnTyp: types.T_float64, 3478 Fn: operator.CaseWhenFloat64, 3479 }, 3480 { 3481 Index: 10, 3482 Volatile: true, 3483 ReturnTyp: types.T_bool, 3484 Fn: operator.CaseWhenBool, 3485 }, 3486 { 3487 Index: 11, 3488 Volatile: true, 3489 ReturnTyp: types.T_date, 3490 Fn: operator.CaseWhenDate, 3491 }, 3492 { 3493 Index: 12, 3494 Volatile: true, 3495 ReturnTyp: types.T_datetime, 3496 Fn: operator.CaseWhenDateTime, 3497 }, 3498 { 3499 Index: 13, 3500 Volatile: true, 3501 ReturnTyp: types.T_varchar, 3502 Fn: operator.CaseWhenVarchar, 3503 }, 3504 { 3505 Index: 14, 3506 Volatile: true, 3507 ReturnTyp: types.T_char, 3508 Fn: operator.CaseWhenChar, 3509 }, 3510 { 3511 Index: 15, 3512 Volatile: true, 3513 ReturnTyp: types.T_decimal64, 3514 Fn: operator.CaseWhenDecimal64, 3515 }, 3516 { 3517 Index: 16, 3518 Volatile: true, 3519 ReturnTyp: types.T_decimal128, 3520 Fn: operator.CaseWhenDecimal128, 3521 }, 3522 { 3523 Index: 17, 3524 Volatile: true, 3525 ReturnTyp: types.T_timestamp, 3526 Fn: operator.CaseWhenTimestamp, 3527 }, 3528 { 3529 Index: 18, 3530 Volatile: true, 3531 ReturnTyp: types.T_blob, 3532 Fn: operator.CaseWhenBlob, 3533 }, 3534 { 3535 Index: 19, 3536 Volatile: true, 3537 ReturnTyp: types.T_uuid, 3538 Fn: operator.CaseWhenUuid, 3539 }, 3540 { 3541 Index: 20, 3542 Volatile: true, 3543 ReturnTyp: types.T_text, 3544 Fn: operator.CaseWhenText, 3545 }, 3546 { 3547 Index: 21, 3548 Volatile: true, 3549 ReturnTyp: types.T_time, 3550 Fn: operator.CaseWhenTime, 3551 }, 3552 { 3553 Index: 22, 3554 Volatile: true, 3555 ReturnTyp: types.T_json, 3556 Fn: operator.CaseWhenJson, 3557 }, 3558 }, 3559 }, 3560 3561 IFF: { 3562 Id: IFF, 3563 Flag: plan.Function_NONE, 3564 Layout: STANDARD_FUNCTION, 3565 TypeCheckFn: func(overloads []Function, inputs []types.T) (overloadIndex int32, ts []types.T) { 3566 for i, o := range overloads { 3567 if operator.IfTypeCheckFn(inputs, nil, o.ReturnTyp) { 3568 return int32(i), nil 3569 } 3570 } 3571 minCost, minIndex := math.MaxInt32, -1 3572 convertTypes := make([]types.T, 3) 3573 targetTypes := make([]types.T, 3) 3574 for i, o := range overloads { 3575 if len(inputs) == 3 { 3576 if inputs[0] != types.T_bool && !inputs[0].ToType().IsIntOrUint() { 3577 continue 3578 } 3579 3580 targetTypes[0] = types.T_bool 3581 targetTypes[1], targetTypes[2] = o.ReturnTyp, o.ReturnTyp 3582 if code, c := tryToMatch(inputs, targetTypes); code == matchedByConvert { 3583 if c < minCost { 3584 minCost = c 3585 copy(convertTypes, targetTypes) 3586 minIndex = i 3587 } 3588 } 3589 } 3590 } 3591 if minIndex != -1 { 3592 return int32(minIndex), convertTypes 3593 } 3594 return wrongFunctionParameters, nil 3595 }, 3596 Overloads: []Function{ 3597 { 3598 Index: 0, 3599 Volatile: true, 3600 ReturnTyp: types.T_int8, 3601 Fn: operator.IfInt8, 3602 }, 3603 { 3604 Index: 1, 3605 Volatile: true, 3606 ReturnTyp: types.T_int16, 3607 Fn: operator.IfInt16, 3608 }, 3609 { 3610 Index: 2, 3611 Volatile: true, 3612 ReturnTyp: types.T_int32, 3613 Fn: operator.IfInt32, 3614 }, 3615 { 3616 Index: 3, 3617 Volatile: true, 3618 ReturnTyp: types.T_int64, 3619 Fn: operator.IfInt64, 3620 }, 3621 { 3622 Index: 4, 3623 Volatile: true, 3624 ReturnTyp: types.T_uint8, 3625 Fn: operator.IfUint8, 3626 }, 3627 { 3628 Index: 5, 3629 Volatile: true, 3630 ReturnTyp: types.T_uint16, 3631 Fn: operator.IfUint16, 3632 }, 3633 { 3634 Index: 6, 3635 Volatile: true, 3636 ReturnTyp: types.T_uint32, 3637 Fn: operator.IfUint32, 3638 }, 3639 { 3640 Index: 7, 3641 Volatile: true, 3642 ReturnTyp: types.T_uint64, 3643 Fn: operator.IfUint64, 3644 }, 3645 { 3646 Index: 8, 3647 Volatile: true, 3648 ReturnTyp: types.T_float32, 3649 Fn: operator.IfFloat32, 3650 }, 3651 { 3652 Index: 9, 3653 Volatile: true, 3654 ReturnTyp: types.T_float64, 3655 Fn: operator.IfFloat64, 3656 }, 3657 { 3658 Index: 10, 3659 Volatile: true, 3660 ReturnTyp: types.T_bool, 3661 Fn: operator.IfBool, 3662 }, 3663 { 3664 Index: 11, 3665 Volatile: true, 3666 ReturnTyp: types.T_date, 3667 Fn: operator.IfDate, 3668 }, 3669 { 3670 Index: 12, 3671 Volatile: true, 3672 ReturnTyp: types.T_datetime, 3673 Fn: operator.IfDateTime, 3674 }, 3675 { 3676 Index: 13, 3677 Volatile: true, 3678 ReturnTyp: types.T_varchar, 3679 Fn: operator.IfVarchar, 3680 }, 3681 { 3682 Index: 14, 3683 Volatile: true, 3684 ReturnTyp: types.T_char, 3685 Fn: operator.IfChar, 3686 }, 3687 { 3688 Index: 15, 3689 Volatile: true, 3690 ReturnTyp: types.T_decimal64, 3691 Fn: operator.IfDecimal64, 3692 }, 3693 { 3694 Index: 16, 3695 Volatile: true, 3696 ReturnTyp: types.T_decimal128, 3697 Fn: operator.IfDecimal128, 3698 }, 3699 { 3700 Index: 17, 3701 Volatile: true, 3702 ReturnTyp: types.T_timestamp, 3703 Fn: operator.IfTimestamp, 3704 }, 3705 { 3706 Index: 18, 3707 Volatile: true, 3708 ReturnTyp: types.T_blob, 3709 Fn: operator.IfBlob, 3710 }, 3711 { 3712 Index: 19, 3713 Volatile: true, 3714 ReturnTyp: types.T_text, 3715 Fn: operator.IfText, 3716 }, 3717 { 3718 Index: 20, 3719 Volatile: true, 3720 ReturnTyp: types.T_time, 3721 Fn: operator.IfTime, 3722 }, 3723 { 3724 Index: 21, 3725 Volatile: true, 3726 ReturnTyp: types.T_json, 3727 Fn: operator.IfJson, 3728 }, 3729 { 3730 Index: 22, 3731 Volatile: true, 3732 ReturnTyp: types.T_uuid, 3733 Fn: operator.IfUuid, 3734 }, 3735 }, 3736 }, 3737 }