github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/plan/function/function_id.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 const ( 18 Distinct = 0x8000000000000000 19 DistinctMask = 0x7FFFFFFFFFFFFFFF 20 ) 21 22 // All function IDs 23 const ( 24 EQUAL = iota // = 25 NOT_EQUAL // <> 26 GREAT_THAN // > 27 GREAT_EQUAL // >= 28 LESS_THAN // < 29 LESS_EQUAL // <= 30 BETWEEN 31 UNARY_PLUS // UNARY_PLUS + 32 UNARY_MINUS // UNARY_MINUS - 33 UNARY_TILDE // UNARY_TILDE ~ 34 PLUS // + 35 MINUS // - 36 MULTI // * 37 DIV // / 38 INTEGER_DIV // Div 39 MOD // % 40 CONCAT // || 41 AND 42 OR 43 XOR 44 NOT 45 CAST 46 BIT_CAST 47 IS 48 ISNOT 49 ISNULL 50 ISNOTNULL 51 ISTRUE 52 ISNOTTRUE 53 ISFALSE 54 ISNOTFALSE 55 ISEMPTY 56 NOT_IN_ROWS 57 OP_BIT_AND // & 58 OP_BIT_OR // | 59 OP_BIT_XOR // ^ 60 OP_BIT_SHIFT_LEFT // << 61 OP_BIT_SHIFT_RIGHT // >> 62 63 ABS 64 ACOS 65 ADDDATE 66 ADDTIME 67 AES_DECRYPT 68 AES_ENCRYPT 69 ANY_VALUE 70 APPROX_COUNT 71 ARRAY_AGG 72 ARRAY_APPEND 73 ARRAY_CAT 74 ARRAY_CONTAINS 75 ARRAY_POSITION 76 ARRAY_SIZE 77 ASCII 78 ASIN 79 ASSERT 80 ATAN 81 ATAN2 82 AVG 83 BASE64_DECODE 84 BASE64_ENCODE 85 BIT_AND 86 BIT_LENGTH 87 BIT_NOT 88 BIT_OR 89 BIT_XOR 90 BITAGG_AND 91 BITAGG_OR 92 BOOLAGG_AND 93 BOOLAGG_OR 94 CASE 95 CEIL 96 CHR 97 COALESCE 98 FIELD 99 CONCAT_WS 100 CONTAINS 101 CORR 102 COS 103 COT 104 COUNT 105 COUNT_IF 106 COVAR_POP 107 COVAR_SAMPLE 108 CONVERT_TZ 109 CUME_DIST 110 CURRENT_DATE 111 CURRENT_TIMESTAMP 112 DATE_FROM_PARTS 113 DATE_PART 114 DATEADD 115 DATEDIFF 116 TIMEDIFF 117 TIMESTAMPDIFF 118 DENSE_RANK 119 EMPTY 120 ENDSWITH 121 EXP 122 FINDINSET 123 FIRST_VALUE 124 FLOOR 125 GREATEST 126 GROUPING_ID 127 HASH 128 HASH_AGG 129 HEX_DECODE 130 HEX_ENCODE 131 HEX 132 UNHEX 133 MD5 134 IFF 135 IFNULL 136 ILIKE 137 ILIKE_ALL 138 ILIKE_ANY 139 IN 140 LAG 141 LAST_VALUE 142 LEAD 143 LEAST 144 LEFT 145 LENGTH 146 LENGTH_UTF8 147 LIKE 148 LIKE_ALL 149 LIKE_ANY 150 LN 151 NOT_IN 152 LOG 153 LOG2 154 LOG10 155 LOWER 156 LPAD 157 LTRIM 158 MAX 159 MEDIAN 160 MIN 161 MODE 162 MONTH 163 NORMAL 164 NTH_VALUE 165 NTILE 166 NULLIF 167 PERCENT_RANK 168 PI 169 POSITION 170 POW 171 PREFIX_EQ 172 PREFIX_IN 173 PREFIX_BETWEEN 174 RADIAN 175 RANDOM 176 RANK 177 REGEXP 178 REGEXP_INSTR 179 REGEXP_LIKE 180 REGEXP_REPLACE 181 REGEXP_SUBSTR 182 REG_MATCH 183 NOT_REG_MATCH 184 REPEAT 185 REPLACE 186 REVERSE 187 RIGHT 188 ROUND 189 ROW_NUMBER 190 RPAD 191 RTRIM 192 SIGN 193 SIN 194 SINH 195 SPACE 196 SPLIT 197 SPLIT_PART 198 SQRT 199 STARCOUNT 200 STARTSWITH 201 STDDEV_POP 202 STDDEV_SAMPLE 203 SUBSTR 204 SUM 205 SYSDATE 206 GROUP_CONCAT 207 TAN 208 TO_DATE 209 STR_TO_DATE 210 TO_INTERVAL 211 TRANSLATE 212 TRIM 213 UNIFORM 214 SHA1 215 SHA2 216 UTC_TIMESTAMP 217 UNIX_TIMESTAMP 218 FROM_UNIXTIME 219 UPPER 220 VAR_POP 221 VAR_SAMPLE 222 223 DATE 224 TIME 225 DAY 226 DAYOFYEAR 227 INTERVAL 228 EXTRACT 229 OCT 230 SUBSTRING 231 ENCODE 232 DECODE 233 TO_BASE64 234 FROM_BASE64 235 SUBSTRING_INDEX 236 WEEK 237 WEEKDAY 238 YEAR 239 HOUR 240 MINUTE 241 SECOND 242 TO_DAYS 243 TO_SECONDS 244 245 DATE_ADD 246 DATE_SUB 247 APPROX_COUNT_DISTINCT 248 249 LOAD_FILE 250 251 //information functions 252 //Reference to : https://dev.mysql.com/doc/refman/8.0/en/information-functions.html 253 DATABASE 254 USER 255 CONNECTION_ID 256 CHARSET 257 CONVERT 258 CURRENT_ROLE 259 FOUND_ROWS 260 ICULIBVERSION 261 LAST_INSERT_ID 262 LAST_QUERY_ID 263 LAST_UUID 264 ROLES_GRAPHML 265 ROW_COUNT 266 VERSION 267 COLLATION 268 CURRENT_ACCOUNT_ID 269 CURRENT_ACCOUNT_NAME 270 CURRENT_ROLE_ID 271 CURRENT_ROLE_NAME 272 CURRENT_USER_ID 273 CURRENT_USER_NAME 274 275 TIMESTAMP 276 DATE_FORMAT 277 JSON_EXTRACT 278 JSON_QUOTE 279 JSON_UNQUOTE 280 FORMAT 281 SLEEP 282 INSTR 283 LOCATE 284 285 UUID 286 SERIAL 287 SERIAL_FULL 288 SERIAL_EXTRACT 289 BIN 290 291 ENABLE_FAULT_INJECTION 292 DISABLE_FAULT_INJECTION 293 ADD_FAULT_POINT // Add a fault point 294 REMOVE_FAULT_POINT // Remove 295 TRIGGER_FAULT_POINT // Trigger. 296 297 MO_MEMORY_USAGE // Dump memory usage 298 MO_ENABLE_MEMORY_USAGE_DETAIL 299 MO_DISABLE_MEMORY_USAGE_DETAIL 300 301 // MO_CTL is used to check some internal status, and issue some ctl commands to the service. 302 // see builtin.ctl.ctl.go to get detail. 303 MO_CTL 304 305 MO_SHOW_VISIBLE_BIN // parse type/onUpdate/default []byte to visible string 306 MO_SHOW_VISIBLE_BIN_ENUM // parse type/onUpdate/default []byte to visible string for enum 307 308 MO_TABLE_ROWS // table rows 309 MO_TABLE_SIZE // table size 310 MO_TABLE_COL_MAX // table column max value 311 MO_TABLE_COL_MIN // table column min value 312 313 MO_LOG_DATE // parse date from string, like __mo_filepath 314 MO_CHECH_LEVEL 315 PURGE_LOG // purge mo internal log, like rawlog, statement_info, metric 316 MO_ADMIN_NAME // get mo admin name of account 317 MO_CU 318 MO_CU_V1 319 320 GIT_VERSION 321 BUILD_VERSION 322 323 // be used: insert into t1 values(1,1) on duplicate key update a=values(a)+a+1 324 VALUES 325 BINARY 326 INTERNAL_CHAR_LENGTH 327 INTERNAL_CHAR_SIZE 328 INTERNAL_NUMERIC_PRECISION 329 INTERNAL_NUMERIC_SCALE 330 INTERNAL_DATETIME_SCALE 331 INTERNAL_COLUMN_CHARACTER_SET 332 INTERNAL_AUTO_INCREMENT 333 334 // be used: enum 335 CAST_INDEX_TO_VALUE 336 CAST_VALUE_TO_INDEX 337 CAST_INDEX_VALUE_TO_INDEX 338 339 // be used: show snapshots 340 CAST_NANO_TO_TIMESTAMP 341 342 //Sequence function 343 NEXTVAL 344 SETVAL 345 CURRVAL 346 LASTVAL 347 348 // Array Function 349 SUMMATION 350 L1_NORM // L1_NORMALIZATION 351 L2_NORM // L2 NORMALIZATION 352 INNER_PRODUCT 353 COSINE_SIMILARITY 354 VECTOR_DIMS //VECTOR DIMENSIONS 355 NORMALIZE_L2 //NORMALIZE L2 356 L2_DISTANCE //L2_DISTANCE 357 COSINE_DISTANCE //COSINE_DISTANCE 358 CLUSTER_CENTERS // CLUSTER_CENTERS 359 SUB_VECTOR // SUB_VECTOR 360 361 PYTHON_UDF 362 363 // observation function 364 MO_CPU 365 MO_MEMORY 366 MO_CPU_DUMP 367 368 // bitmap function 369 BITMAP_BIT_POSITION 370 BITMAP_BUCKET_NUMBER 371 BITMAP_COUNT 372 BITMAP_CONSTRUCT_AGG 373 BITMAP_OR_AGG 374 375 // FUNCTION_END_NUMBER is not a function, just a flag to record the max number of function. 376 // TODO: every one should put the new function id in front of this one if you want to make a new function. 377 FUNCTION_END_NUMBER 378 ) 379 380 // functionIdRegister is what function we have registered already. 381 var functionIdRegister = map[string]int32{ 382 // operators 383 "=": EQUAL, 384 ">": GREAT_THAN, 385 ">=": GREAT_EQUAL, 386 "<": LESS_THAN, 387 "<=": LESS_EQUAL, 388 "<>": NOT_EQUAL, 389 "!=": NOT_EQUAL, 390 "not": NOT, 391 "and": AND, 392 "or": OR, 393 "xor": XOR, 394 "like": LIKE, 395 "between": BETWEEN, 396 "in": IN, 397 "not_in": NOT_IN, 398 "+": PLUS, 399 "-": MINUS, 400 "*": MULTI, 401 "/": DIV, 402 "div": INTEGER_DIV, 403 "%": MOD, 404 "mod": MOD, 405 "unary_plus": UNARY_PLUS, 406 "unary_minus": UNARY_MINUS, 407 "unary_tilde": UNARY_TILDE, 408 "unary_mark": NOT, 409 "case": CASE, 410 "coalesce": COALESCE, 411 "cast": CAST, 412 "bit_cast": BIT_CAST, 413 "is": IS, 414 "is_not": ISNOT, 415 "isnot": ISNOT, 416 "is_null": ISNULL, 417 "isnull": ISNULL, 418 "ifnull": ISNULL, 419 "ilike": ILIKE, 420 "is_not_null": ISNOTNULL, 421 "isnotnull": ISNOTNULL, 422 "isunknown": ISNULL, 423 "isnotunknown": ISNOTNULL, 424 "istrue": ISTRUE, 425 "isnottrue": ISNOTTRUE, 426 "isfalse": ISFALSE, 427 "isnotfalse": ISNOTFALSE, 428 "&": OP_BIT_AND, 429 "|": OP_BIT_OR, 430 "^": OP_BIT_XOR, 431 "<<": OP_BIT_SHIFT_LEFT, 432 ">>": OP_BIT_SHIFT_RIGHT, 433 "decode": DECODE, 434 "prefix_eq": PREFIX_EQ, 435 "prefix_in": PREFIX_IN, 436 "prefix_between": PREFIX_BETWEEN, 437 // aggregate 438 "max": MAX, 439 "min": MIN, 440 "sum": SUM, 441 "group_concat": GROUP_CONCAT, 442 "avg": AVG, 443 "count": COUNT, 444 "starcount": STARCOUNT, 445 "bit_or": BIT_OR, 446 "bit_and": BIT_AND, 447 "bit_xor": BIT_XOR, 448 "cluster_centers": CLUSTER_CENTERS, 449 "subvector": SUB_VECTOR, 450 "std": STDDEV_POP, 451 "stddev_pop": STDDEV_POP, 452 "variance": VAR_POP, 453 "var_pop": VAR_POP, 454 "approx_count": APPROX_COUNT, 455 "approx_count_distinct": APPROX_COUNT_DISTINCT, 456 "any_value": ANY_VALUE, 457 "median": MEDIAN, 458 // count window 459 "rank": RANK, 460 // builtin 461 // whoever edit this, please follow the lexical order, or come up with a better ordering method 462 // binary functions 463 "endswith": ENDSWITH, 464 "findinset": FINDINSET, 465 "find_in_set": FINDINSET, 466 "power": POW, 467 "startswith": STARTSWITH, 468 "to_date": STR_TO_DATE, 469 "str_to_date": STR_TO_DATE, 470 "date_format": DATE_FORMAT, 471 // whoever edit this, please follow the lexical order, or come up with a better ordering method 472 // variadic functions 473 "ceil": CEIL, 474 "ceiling": CEIL, 475 "concat_ws": CONCAT_WS, 476 "concat": CONCAT, 477 "current_timestamp": CURRENT_TIMESTAMP, 478 "now": CURRENT_TIMESTAMP, 479 "sysdate": SYSDATE, 480 "floor": FLOOR, 481 "lpad": LPAD, 482 "pi": PI, 483 "round": ROUND, 484 "rpad": RPAD, 485 "substr": SUBSTRING, 486 "substring": SUBSTRING, 487 "mid": SUBSTRING, 488 "encode": ENCODE, 489 "utc_timestamp": UTC_TIMESTAMP, 490 "unix_timestamp": UNIX_TIMESTAMP, 491 "from_unixtime": FROM_UNIXTIME, 492 "left": LEFT, 493 // unary functions 494 // whoever edit this, please follow the lexical order, or come up with a better ordering method 495 "abs": ABS, 496 "acos": ACOS, 497 "assert": ASSERT, 498 "bit_length": BIT_LENGTH, 499 "date": DATE, 500 "time": TIME, 501 "hour": HOUR, 502 "minute": MINUTE, 503 "second": SECOND, 504 "sqrt": SQRT, 505 "to_seconds": TO_SECONDS, 506 "day": DAY, 507 "to_days": TO_DAYS, 508 "dayofyear": DAYOFYEAR, 509 "exp": EXP, 510 "empty": EMPTY, 511 "length": LENGTH, 512 "lengthutf8": LENGTH_UTF8, 513 "char_length": LENGTH_UTF8, 514 "ln": LN, 515 "log": LOG, 516 "log2": LOG2, 517 "log10": LOG10, 518 "ltrim": LTRIM, 519 "month": MONTH, 520 "not_in_rows": NOT_IN_ROWS, 521 "oct": OCT, 522 "rand": RANDOM, 523 "reverse": REVERSE, 524 "rtrim": RTRIM, 525 "sin": SIN, 526 "sinh": SINH, 527 "space": SPACE, 528 "tan": TAN, 529 "week": WEEK, 530 "weekday": WEEKDAY, 531 "year": YEAR, 532 "extract": EXTRACT, 533 "if": IFF, 534 "iff": IFF, 535 "isempty": ISEMPTY, 536 "date_add": DATE_ADD, 537 "date_sub": DATE_SUB, 538 "atan": ATAN, 539 "cos": COS, 540 "cot": COT, 541 "timestamp": TIMESTAMP, 542 "database": DATABASE, 543 "schema": DATABASE, 544 "user": USER, 545 "system_user": USER, 546 "session_user": USER, 547 "current_user": USER, 548 "connection_id": CONNECTION_ID, 549 "charset": CHARSET, 550 "convert": CONVERT, 551 "convert_tz": CONVERT_TZ, 552 "current_account_id": CURRENT_ACCOUNT_ID, 553 "current_account_name": CURRENT_ACCOUNT_NAME, 554 "current_role": CURRENT_ROLE, 555 "current_role_id": CURRENT_ROLE_ID, 556 "current_role_name": CURRENT_ROLE_NAME, 557 "current_user_id": CURRENT_USER_ID, 558 "current_user_name": CURRENT_USER_NAME, 559 "found_rows": FOUND_ROWS, 560 "icu_version": ICULIBVERSION, 561 "last_insert_id": LAST_INSERT_ID, 562 "last_query_id": LAST_QUERY_ID, 563 "last_uuid": LAST_QUERY_ID, 564 "roles_graphml": ROLES_GRAPHML, 565 "row_count": ROW_COUNT, 566 "row_number": ROW_NUMBER, 567 "version": VERSION, 568 "collation": COLLATION, 569 "json_extract": JSON_EXTRACT, 570 "json_quote": JSON_QUOTE, 571 "enable_fault_injection": ENABLE_FAULT_INJECTION, 572 "disable_fault_injection": DISABLE_FAULT_INJECTION, 573 "dense_rank": DENSE_RANK, 574 "add_fault_point": ADD_FAULT_POINT, 575 "remove_fault_point": REMOVE_FAULT_POINT, 576 "trigger_fault_point": TRIGGER_FAULT_POINT, 577 "uuid": UUID, 578 "load_file": LOAD_FILE, 579 "hex": HEX, 580 "unhex": UNHEX, 581 "md5": MD5, 582 "to_base64": TO_BASE64, 583 "from_base64": FROM_BASE64, 584 "serial": SERIAL, 585 "serial_full": SERIAL_FULL, 586 "serial_extract": SERIAL_EXTRACT, 587 "hash_value": HASH, 588 "bin": BIN, 589 "datediff": DATEDIFF, 590 "timestampdiff": TIMESTAMPDIFF, 591 "timediff": TIMEDIFF, 592 "reg_match": REG_MATCH, 593 "not_reg_match": NOT_REG_MATCH, 594 "regexp_instr": REGEXP_INSTR, 595 "regexp_like": REGEXP_LIKE, 596 "regexp_replace": REGEXP_REPLACE, 597 "regexp_substr": REGEXP_SUBSTR, 598 "repeat": REPEAT, 599 "mo_memory_usage": MO_MEMORY_USAGE, 600 "mo_enable_memory_usage_detail": MO_ENABLE_MEMORY_USAGE_DETAIL, 601 "mo_disable_memory_usage_detail": MO_DISABLE_MEMORY_USAGE_DETAIL, 602 "mo_ctl": MO_CTL, 603 "mo_show_visible_bin": MO_SHOW_VISIBLE_BIN, 604 "mo_show_visible_bin_enum": MO_SHOW_VISIBLE_BIN_ENUM, 605 "substring_index": SUBSTRING_INDEX, 606 "field": FIELD, 607 "format": FORMAT, 608 "sleep": SLEEP, 609 "split_part": SPLIT_PART, 610 "instr": INSTR, 611 "locate": LOCATE, 612 "curdate": CURRENT_DATE, 613 "current_date": CURRENT_DATE, 614 "json_unquote": JSON_UNQUOTE, 615 "ascii": ASCII, 616 "replace": REPLACE, 617 "mo_table_rows": MO_TABLE_ROWS, 618 "mo_table_size": MO_TABLE_SIZE, 619 "mo_table_col_max": MO_TABLE_COL_MAX, 620 "mo_table_col_min": MO_TABLE_COL_MIN, 621 "trim": TRIM, 622 "sha2": SHA2, 623 "mo_log_date": MO_LOG_DATE, 624 "mo_check_level": MO_CHECH_LEVEL, 625 "purge_log": PURGE_LOG, 626 "mo_admin_name": MO_ADMIN_NAME, 627 "mo_cu": MO_CU, 628 "mo_cu_v1": MO_CU_V1, 629 "git_version": GIT_VERSION, 630 "build_version": BUILD_VERSION, 631 "values": VALUES, 632 "binary": BINARY, 633 "internal_char_length": INTERNAL_CHAR_LENGTH, 634 "internal_char_size": INTERNAL_CHAR_SIZE, 635 "internal_numeric_precision": INTERNAL_NUMERIC_PRECISION, 636 "internal_numeric_scale": INTERNAL_NUMERIC_SCALE, 637 "internal_datetime_scale": INTERNAL_DATETIME_SCALE, 638 "internal_column_character_set": INTERNAL_COLUMN_CHARACTER_SET, 639 "internal_auto_increment": INTERNAL_AUTO_INCREMENT, 640 "nextval": NEXTVAL, 641 "setval": SETVAL, 642 "currval": CURRVAL, 643 "lastval": LASTVAL, 644 "cast_index_to_value": CAST_INDEX_TO_VALUE, 645 "cast_value_to_index": CAST_VALUE_TO_INDEX, 646 "cast_index_value_to_index": CAST_INDEX_VALUE_TO_INDEX, 647 "cast_nano_to_timestamp": CAST_NANO_TO_TIMESTAMP, 648 "to_upper": UPPER, 649 "upper": UPPER, 650 "ucase": UPPER, 651 "to_lower": LOWER, 652 "lower": LOWER, 653 "lcase": LOWER, 654 "sha1": SHA1, 655 "sha": SHA1, 656 657 "summation": SUMMATION, 658 "l1_norm": L1_NORM, 659 "l2_norm": L2_NORM, 660 "inner_product": INNER_PRODUCT, 661 "cosine_similarity": COSINE_SIMILARITY, 662 "vector_dims": VECTOR_DIMS, 663 "normalize_l2": NORMALIZE_L2, 664 "l2_distance": L2_DISTANCE, 665 "cosine_distance": COSINE_DISTANCE, 666 667 "python_user_defined_function": PYTHON_UDF, 668 669 "mo_cpu": MO_CPU, 670 "mo_memory": MO_MEMORY, 671 "mo_cpu_dump": MO_CPU_DUMP, 672 // bitmap function 673 "bitmap_bit_position": BITMAP_BIT_POSITION, 674 "bitmap_bucket_number": BITMAP_BUCKET_NUMBER, 675 "bitmap_count": BITMAP_COUNT, 676 "bitmap_construct_agg": BITMAP_CONSTRUCT_AGG, 677 "bitmap_or_agg": BITMAP_OR_AGG, 678 }