github.com/matrixorigin/matrixone@v0.7.0/pkg/sql/plan/function/aggregate.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 20 "github.com/matrixorigin/matrixone/pkg/container/types" 21 "github.com/matrixorigin/matrixone/pkg/pb/plan" 22 "github.com/matrixorigin/matrixone/pkg/sql/colexec/agg" 23 "github.com/matrixorigin/matrixone/pkg/sql/plan/function/operator" 24 ) 25 26 func initAggregateFunction() { 27 var err error 28 29 for fid, fs := range aggregates { 30 err = appendFunction(context.Background(), fid, fs) 31 if err != nil { 32 panic(err) 33 } 34 } 35 } 36 37 // aggregates contains the aggregate function indexed by function id. 38 var aggregates = map[int]Functions{ 39 // we register group_concat here, but we won't implement it 40 // in agg skeleton 41 GROUP_CONCAT: { 42 Id: GROUP_CONCAT, 43 Flag: plan.Function_AGG, 44 Layout: STANDARD_FUNCTION, 45 TypeCheckFn: func(overloads []Function, inputs []types.T) (overloadIndex int32, ts []types.T) { 46 return 0, nil 47 }, 48 Overloads: []Function{ 49 { 50 Index: 0, 51 ReturnTyp: types.T_text, 52 AggregateInfo: agg.AggregateGroupConcat, 53 }, 54 }, 55 }, 56 MAX: { 57 Id: MAX, 58 Flag: plan.Function_AGG, 59 Layout: STANDARD_FUNCTION, 60 TypeCheckFn: generalTypeCheckForUnaryAggregate, 61 Overloads: []Function{ 62 { 63 Index: 0, 64 Args: []types.T{types.T_uint8}, 65 ReturnTyp: types.T_uint8, 66 AggregateInfo: agg.AggregateMax, 67 }, 68 { 69 Index: 1, 70 Args: []types.T{types.T_uint16}, 71 ReturnTyp: types.T_uint16, 72 AggregateInfo: agg.AggregateMax, 73 }, 74 { 75 Index: 2, 76 Args: []types.T{types.T_uint32}, 77 ReturnTyp: types.T_uint32, 78 AggregateInfo: agg.AggregateMax, 79 }, 80 { 81 Index: 3, 82 Args: []types.T{types.T_uint64}, 83 ReturnTyp: types.T_uint64, 84 AggregateInfo: agg.AggregateMax, 85 }, 86 { 87 Index: 4, 88 Args: []types.T{types.T_int8}, 89 ReturnTyp: types.T_int8, 90 AggregateInfo: agg.AggregateMax, 91 }, 92 { 93 Index: 5, 94 Args: []types.T{types.T_int16}, 95 ReturnTyp: types.T_int16, 96 AggregateInfo: agg.AggregateMax, 97 }, 98 { 99 Index: 6, 100 Args: []types.T{types.T_int32}, 101 ReturnTyp: types.T_int32, 102 AggregateInfo: agg.AggregateMax, 103 }, 104 { 105 Index: 7, 106 Args: []types.T{types.T_int64}, 107 ReturnTyp: types.T_int64, 108 AggregateInfo: agg.AggregateMax, 109 }, 110 { 111 Index: 8, 112 Args: []types.T{types.T_float32}, 113 ReturnTyp: types.T_float32, 114 AggregateInfo: agg.AggregateMax, 115 }, 116 { 117 Index: 9, 118 Args: []types.T{types.T_float64}, 119 ReturnTyp: types.T_float64, 120 AggregateInfo: agg.AggregateMax, 121 }, 122 { 123 Index: 10, 124 Args: []types.T{types.T_date}, 125 ReturnTyp: types.T_date, 126 AggregateInfo: agg.AggregateMax, 127 }, 128 { 129 Index: 11, 130 Args: []types.T{types.T_datetime}, 131 ReturnTyp: types.T_datetime, 132 AggregateInfo: agg.AggregateMax, 133 }, 134 { 135 Index: 12, 136 Args: []types.T{types.T_timestamp}, 137 ReturnTyp: types.T_timestamp, 138 AggregateInfo: agg.AggregateMax, 139 }, 140 { 141 Index: 13, 142 Args: []types.T{types.T_decimal64}, 143 ReturnTyp: types.T_decimal64, 144 AggregateInfo: agg.AggregateMax, 145 }, 146 { 147 Index: 14, 148 Args: []types.T{types.T_decimal128}, 149 ReturnTyp: types.T_decimal128, 150 AggregateInfo: agg.AggregateMax, 151 }, 152 { 153 Index: 15, 154 Args: []types.T{types.T_bool}, 155 ReturnTyp: types.T_bool, 156 AggregateInfo: agg.AggregateMax, 157 }, 158 { 159 Index: 16, 160 Args: []types.T{types.T_varchar}, 161 ReturnTyp: types.T_varchar, 162 AggregateInfo: agg.AggregateMax, 163 }, 164 { 165 Index: 17, 166 Args: []types.T{types.T_char}, 167 ReturnTyp: types.T_char, 168 AggregateInfo: agg.AggregateMax, 169 }, 170 { 171 Index: 18, 172 Args: []types.T{types.T_blob}, 173 ReturnTyp: types.T_blob, 174 AggregateInfo: agg.AggregateMax, 175 }, 176 { 177 Index: 19, 178 Args: []types.T{types.T_uuid}, 179 ReturnTyp: types.T_uuid, 180 AggregateInfo: agg.AggregateMax, 181 }, 182 { 183 Index: 20, 184 Args: []types.T{types.T_text}, 185 ReturnTyp: types.T_text, 186 AggregateInfo: agg.AggregateMax, 187 }, 188 { 189 Index: 21, 190 Args: []types.T{types.T_time}, 191 ReturnTyp: types.T_time, 192 AggregateInfo: agg.AggregateMax, 193 }, 194 }, 195 }, 196 MIN: { 197 Id: MIN, 198 Flag: plan.Function_AGG, 199 Layout: STANDARD_FUNCTION, 200 TypeCheckFn: generalTypeCheckForUnaryAggregate, 201 Overloads: []Function{ 202 { 203 Index: 0, 204 Args: []types.T{types.T_uint8}, 205 ReturnTyp: types.T_uint8, 206 AggregateInfo: agg.AggregateMin, 207 }, 208 { 209 Index: 1, 210 Args: []types.T{types.T_uint16}, 211 ReturnTyp: types.T_uint16, 212 AggregateInfo: agg.AggregateMin, 213 }, 214 { 215 Index: 2, 216 Args: []types.T{types.T_uint32}, 217 ReturnTyp: types.T_uint32, 218 AggregateInfo: agg.AggregateMin, 219 }, 220 { 221 Index: 3, 222 Args: []types.T{types.T_uint64}, 223 ReturnTyp: types.T_uint64, 224 AggregateInfo: agg.AggregateMin, 225 }, 226 { 227 Index: 4, 228 Args: []types.T{types.T_int8}, 229 ReturnTyp: types.T_int8, 230 AggregateInfo: agg.AggregateMin, 231 }, 232 { 233 Index: 5, 234 Args: []types.T{types.T_int16}, 235 ReturnTyp: types.T_int16, 236 AggregateInfo: agg.AggregateMin, 237 }, 238 { 239 Index: 6, 240 Args: []types.T{types.T_int32}, 241 ReturnTyp: types.T_int32, 242 AggregateInfo: agg.AggregateMin, 243 }, 244 { 245 Index: 7, 246 Args: []types.T{types.T_int64}, 247 ReturnTyp: types.T_int64, 248 AggregateInfo: agg.AggregateMin, 249 }, 250 { 251 Index: 8, 252 Args: []types.T{types.T_float32}, 253 ReturnTyp: types.T_float32, 254 AggregateInfo: agg.AggregateMin, 255 }, 256 { 257 Index: 9, 258 Args: []types.T{types.T_float64}, 259 ReturnTyp: types.T_float64, 260 AggregateInfo: agg.AggregateMin, 261 }, 262 { 263 Index: 10, 264 Args: []types.T{types.T_date}, 265 ReturnTyp: types.T_date, 266 AggregateInfo: agg.AggregateMin, 267 }, 268 { 269 Index: 11, 270 Args: []types.T{types.T_datetime}, 271 ReturnTyp: types.T_datetime, 272 AggregateInfo: agg.AggregateMin, 273 }, 274 { 275 Index: 12, 276 Args: []types.T{types.T_timestamp}, 277 ReturnTyp: types.T_timestamp, 278 AggregateInfo: agg.AggregateMin, 279 }, 280 { 281 Index: 13, 282 Args: []types.T{types.T_decimal64}, 283 ReturnTyp: types.T_decimal64, 284 AggregateInfo: agg.AggregateMin, 285 }, 286 { 287 Index: 14, 288 Args: []types.T{types.T_decimal128}, 289 ReturnTyp: types.T_decimal128, 290 AggregateInfo: agg.AggregateMin, 291 }, 292 { 293 Index: 15, 294 Args: []types.T{types.T_bool}, 295 ReturnTyp: types.T_bool, 296 AggregateInfo: agg.AggregateMin, 297 }, 298 { 299 Index: 16, 300 Args: []types.T{types.T_varchar}, 301 ReturnTyp: types.T_varchar, 302 AggregateInfo: agg.AggregateMin, 303 }, 304 { 305 Index: 17, 306 Args: []types.T{types.T_char}, 307 ReturnTyp: types.T_char, 308 AggregateInfo: agg.AggregateMin, 309 }, { 310 Index: 18, 311 Args: []types.T{types.T_blob}, 312 ReturnTyp: types.T_blob, 313 AggregateInfo: agg.AggregateMin, 314 }, { 315 Index: 19, 316 Args: []types.T{types.T_uuid}, 317 ReturnTyp: types.T_uuid, 318 AggregateInfo: agg.AggregateMin, 319 }, 320 { 321 Index: 20, 322 Args: []types.T{types.T_text}, 323 ReturnTyp: types.T_text, 324 AggregateInfo: agg.AggregateMin, 325 }, 326 { 327 Index: 21, 328 Args: []types.T{types.T_time}, 329 ReturnTyp: types.T_time, 330 AggregateInfo: agg.AggregateMin, 331 }, 332 }, 333 }, 334 SUM: { 335 Id: SUM, 336 Flag: plan.Function_AGG, 337 Layout: STANDARD_FUNCTION, 338 TypeCheckFn: generalTypeCheckForUnaryAggregate, 339 Overloads: []Function{ 340 { 341 Index: 0, 342 Args: []types.T{types.T_uint8}, 343 ReturnTyp: types.T_uint64, 344 AggregateInfo: agg.AggregateSum, 345 }, 346 { 347 Index: 1, 348 Args: []types.T{types.T_uint16}, 349 ReturnTyp: types.T_uint64, 350 AggregateInfo: agg.AggregateSum, 351 }, 352 { 353 Index: 2, 354 Args: []types.T{types.T_uint32}, 355 ReturnTyp: types.T_uint64, 356 AggregateInfo: agg.AggregateSum, 357 }, 358 { 359 Index: 3, 360 Args: []types.T{types.T_uint64}, 361 ReturnTyp: types.T_uint64, 362 AggregateInfo: agg.AggregateSum, 363 }, 364 { 365 Index: 4, 366 Args: []types.T{types.T_int8}, 367 ReturnTyp: types.T_int64, 368 AggregateInfo: agg.AggregateSum, 369 }, 370 { 371 Index: 5, 372 Args: []types.T{types.T_int16}, 373 ReturnTyp: types.T_int64, 374 AggregateInfo: agg.AggregateSum, 375 }, 376 { 377 Index: 6, 378 Args: []types.T{types.T_int32}, 379 ReturnTyp: types.T_int64, 380 AggregateInfo: agg.AggregateSum, 381 }, 382 { 383 Index: 7, 384 Args: []types.T{types.T_int64}, 385 ReturnTyp: types.T_int64, 386 AggregateInfo: agg.AggregateSum, 387 }, 388 { 389 Index: 8, 390 Args: []types.T{types.T_float32}, 391 ReturnTyp: types.T_float64, 392 AggregateInfo: agg.AggregateSum, 393 }, 394 { 395 Index: 9, 396 Args: []types.T{types.T_float64}, 397 ReturnTyp: types.T_float64, 398 AggregateInfo: agg.AggregateSum, 399 }, 400 /* 401 { 402 Index: 10, 403 Args: []types.T{types.T_date}, 404 TypeCheckFn: strictTypeCheck, 405 ReturnTyp: types.T_date, 406 AggregateInfo: agg.Sum, 407 }, 408 { 409 Index: 11, 410 Args: []types.T{types.T_datetime}, 411 TypeCheckFn: strictTypeCheck, 412 ReturnTyp: types.T_datetime, 413 AggregateInfo: agg.Sum, 414 }, 415 */ 416 { 417 Index: 10, 418 Args: []types.T{types.T_decimal64}, 419 ReturnTyp: types.T_decimal64, 420 AggregateInfo: agg.AggregateSum, 421 }, 422 { 423 Index: 11, 424 Args: []types.T{types.T_decimal128}, 425 ReturnTyp: types.T_decimal128, 426 AggregateInfo: agg.AggregateSum, 427 }, 428 }, 429 }, 430 AVG: { 431 Id: AVG, 432 Flag: plan.Function_AGG, 433 Layout: STANDARD_FUNCTION, 434 TypeCheckFn: generalTypeCheckForUnaryAggregate, 435 Overloads: []Function{ 436 { 437 Index: 0, 438 Args: []types.T{types.T_uint8}, 439 ReturnTyp: types.T_float64, 440 AggregateInfo: agg.AggregateAvg, 441 }, 442 { 443 Index: 1, 444 Args: []types.T{types.T_uint16}, 445 ReturnTyp: types.T_float64, 446 AggregateInfo: agg.AggregateAvg, 447 }, 448 { 449 Index: 2, 450 Args: []types.T{types.T_uint32}, 451 ReturnTyp: types.T_float64, 452 AggregateInfo: agg.AggregateAvg, 453 }, 454 { 455 Index: 3, 456 Args: []types.T{types.T_uint64}, 457 ReturnTyp: types.T_float64, 458 AggregateInfo: agg.AggregateAvg, 459 }, 460 { 461 Index: 4, 462 Args: []types.T{types.T_int8}, 463 ReturnTyp: types.T_float64, 464 AggregateInfo: agg.AggregateAvg, 465 }, 466 { 467 Index: 5, 468 Args: []types.T{types.T_int16}, 469 ReturnTyp: types.T_float64, 470 AggregateInfo: agg.AggregateAvg, 471 }, 472 { 473 Index: 6, 474 Args: []types.T{types.T_int32}, 475 ReturnTyp: types.T_float64, 476 AggregateInfo: agg.AggregateAvg, 477 }, 478 { 479 Index: 7, 480 Args: []types.T{types.T_int64}, 481 ReturnTyp: types.T_float64, 482 AggregateInfo: agg.AggregateAvg, 483 }, 484 { 485 Index: 8, 486 Args: []types.T{types.T_float32}, 487 ReturnTyp: types.T_float64, 488 AggregateInfo: agg.AggregateAvg, 489 }, 490 { 491 Index: 9, 492 Args: []types.T{types.T_float64}, 493 ReturnTyp: types.T_float64, 494 AggregateInfo: agg.AggregateAvg, 495 }, 496 { 497 Index: 10, 498 Args: []types.T{types.T_decimal64}, 499 ReturnTyp: types.T_decimal128, 500 AggregateInfo: agg.AggregateAvg, 501 }, 502 { 503 Index: 11, 504 Args: []types.T{types.T_decimal128}, 505 ReturnTyp: types.T_decimal128, 506 AggregateInfo: agg.AggregateAvg, 507 }, 508 }, 509 }, 510 COUNT: { 511 Id: COUNT, 512 Flag: plan.Function_AGG | plan.Function_PRODUCE_NO_NULL, 513 Layout: STANDARD_FUNCTION, 514 TypeCheckFn: func(_ []Function, inputs []types.T) (overloadIndex int32, _ []types.T) { 515 if len(inputs) == 1 { 516 return 0, nil 517 } 518 return wrongFunctionParameters, nil 519 }, 520 Overloads: []Function{ 521 { 522 Index: 0, 523 ReturnTyp: types.T_int64, 524 AggregateInfo: agg.AggregateCount, 525 }, 526 }, 527 }, 528 STARCOUNT: { 529 Id: STARCOUNT, 530 Flag: plan.Function_AGG | plan.Function_PRODUCE_NO_NULL, 531 Layout: STANDARD_FUNCTION, 532 TypeCheckFn: func(_ []Function, inputs []types.T) (overloadIndex int32, _ []types.T) { 533 if len(inputs) == 1 { 534 return 0, nil 535 } 536 return wrongFunctionParameters, nil 537 }, 538 Overloads: []Function{ 539 { 540 Index: 0, 541 ReturnTyp: types.T_int64, 542 AggregateInfo: agg.AggregateStarCount, 543 }, 544 }, 545 }, 546 BIT_AND: { 547 Id: BIT_AND, 548 Flag: plan.Function_AGG, 549 Layout: STANDARD_FUNCTION, 550 TypeCheckFn: func(_ []Function, inputs []types.T) (overloadIndex int32, _ []types.T) { 551 if len(inputs) == 1 { 552 if inputs[0] == types.T_any { 553 return 0, nil 554 } 555 if !operator.IsNumeric(inputs[0]) && !operator.IsDecimal(inputs[0]) { 556 return wrongFuncParamForAgg, nil 557 } 558 _, err := agg.ReturnType(agg.AggregateBitAnd, types.Type{Oid: inputs[0]}) 559 if err == nil { 560 return 0, nil 561 } 562 } 563 return wrongFunctionParameters, nil 564 }, 565 Overloads: []Function{ 566 { 567 Index: 0, 568 ReturnTyp: types.T_uint64, 569 AggregateInfo: agg.AggregateBitAnd, 570 }, 571 }, 572 }, 573 BIT_OR: { 574 Id: BIT_OR, 575 Flag: plan.Function_AGG, 576 Layout: STANDARD_FUNCTION, 577 TypeCheckFn: func(_ []Function, inputs []types.T) (overloadIndex int32, _ []types.T) { 578 if len(inputs) == 1 { 579 if inputs[0] == types.T_any { 580 return 0, nil 581 } 582 if !operator.IsNumeric(inputs[0]) && !operator.IsDecimal(inputs[0]) { 583 return wrongFuncParamForAgg, nil 584 } 585 _, err := agg.ReturnType(agg.AggregateBitOr, types.Type{Oid: inputs[0]}) 586 if err == nil { 587 return 0, nil 588 } 589 } 590 return wrongFunctionParameters, nil 591 }, 592 Overloads: []Function{ 593 { 594 Index: 0, 595 ReturnTyp: types.T_uint64, 596 AggregateInfo: agg.AggregateBitOr, 597 }, 598 }, 599 }, 600 BIT_XOR: { 601 Id: BIT_XOR, 602 Flag: plan.Function_AGG, 603 Layout: STANDARD_FUNCTION, 604 TypeCheckFn: func(_ []Function, inputs []types.T) (overloadIndex int32, _ []types.T) { 605 if len(inputs) == 1 { 606 if inputs[0] == types.T_any { 607 return 0, nil 608 } 609 if !operator.IsNumeric(inputs[0]) && !operator.IsDecimal(inputs[0]) { 610 return wrongFuncParamForAgg, nil 611 } 612 _, err := agg.ReturnType(agg.AggregateBitXor, types.Type{Oid: inputs[0]}) 613 if err == nil { 614 return 0, nil 615 } 616 } 617 return wrongFunctionParameters, nil 618 }, 619 Overloads: []Function{ 620 { 621 Index: 0, 622 ReturnTyp: types.T_uint64, 623 AggregateInfo: agg.AggregateBitXor, 624 }, 625 }, 626 }, 627 VAR_POP: { 628 Id: VAR_POP, 629 Flag: plan.Function_AGG, 630 Layout: STANDARD_FUNCTION, 631 TypeCheckFn: func(_ []Function, inputs []types.T) (overloadIndex int32, _ []types.T) { 632 if len(inputs) == 1 { 633 if inputs[0] == types.T_any { 634 return 0, nil 635 } 636 if !operator.IsNumeric(inputs[0]) && !operator.IsDecimal(inputs[0]) { 637 return wrongFuncParamForAgg, nil 638 } 639 t, err := agg.ReturnType(agg.AggregateVariance, types.Type{Oid: inputs[0]}) 640 if err != nil { 641 return wrongFunctionParameters, nil 642 } 643 if t.Oid == types.T_decimal128 { 644 return 1, nil 645 } 646 return 0, nil 647 } 648 return wrongFunctionParameters, nil 649 }, 650 Overloads: []Function{ 651 { 652 Index: 0, 653 ReturnTyp: types.T_float64, 654 AggregateInfo: agg.AggregateVariance, 655 }, 656 { 657 Index: 1, 658 ReturnTyp: types.T_decimal128, 659 AggregateInfo: agg.AggregateVariance, 660 }, 661 }, 662 }, 663 STDDEV_POP: { 664 Id: STDDEV_POP, 665 Flag: plan.Function_AGG, 666 Layout: STANDARD_FUNCTION, 667 TypeCheckFn: func(_ []Function, inputs []types.T) (overloadIndex int32, _ []types.T) { 668 if len(inputs) == 1 { 669 if inputs[0] == types.T_any { 670 return 0, nil 671 } 672 if !operator.IsNumeric(inputs[0]) && !operator.IsDecimal(inputs[0]) { 673 return wrongFuncParamForAgg, nil 674 } 675 t, err := agg.ReturnType(agg.AggregateStdDevPop, types.Type{Oid: inputs[0]}) 676 if err != nil { 677 return wrongFunctionParameters, nil 678 } 679 if t.Oid == types.T_decimal128 { 680 return 1, nil 681 } 682 return 0, nil 683 } 684 return wrongFunctionParameters, nil 685 }, 686 Overloads: []Function{ 687 { 688 Index: 0, 689 ReturnTyp: types.T_float64, 690 AggregateInfo: agg.AggregateStdDevPop, 691 }, 692 { 693 Index: 1, 694 ReturnTyp: types.T_decimal128, 695 AggregateInfo: agg.AggregateStdDevPop, 696 }, 697 }, 698 }, 699 APPROX_COUNT_DISTINCT: { 700 Id: APPROX_COUNT_DISTINCT, 701 Flag: plan.Function_AGG, 702 Layout: STANDARD_FUNCTION, 703 TypeCheckFn: func(_ []Function, inputs []types.T) (overloadIndex int32, ts []types.T) { 704 if len(inputs) == 1 { 705 return 0, nil 706 } 707 return wrongFunctionParameters, nil 708 }, 709 Overloads: []Function{ 710 { 711 Index: 0, 712 ReturnTyp: types.T_uint64, 713 AggregateInfo: agg.AggregateApproxCountDistinct, 714 }, 715 }, 716 }, 717 ANY_VALUE: { 718 Id: ANY_VALUE, 719 Flag: plan.Function_AGG, 720 Layout: STANDARD_FUNCTION, 721 TypeCheckFn: generalTypeCheckForUnaryAggregate, 722 Overloads: []Function{ 723 { 724 Index: 0, 725 Args: []types.T{types.T_uint8}, 726 ReturnTyp: types.T_uint8, 727 AggregateInfo: agg.AggregateAnyValue, 728 }, 729 { 730 Index: 1, 731 Args: []types.T{types.T_uint16}, 732 ReturnTyp: types.T_uint16, 733 AggregateInfo: agg.AggregateAnyValue, 734 }, 735 { 736 Index: 2, 737 Args: []types.T{types.T_uint32}, 738 ReturnTyp: types.T_uint32, 739 AggregateInfo: agg.AggregateAnyValue, 740 }, 741 { 742 Index: 3, 743 Args: []types.T{types.T_uint64}, 744 ReturnTyp: types.T_uint64, 745 AggregateInfo: agg.AggregateAnyValue, 746 }, 747 { 748 Index: 4, 749 Args: []types.T{types.T_int8}, 750 ReturnTyp: types.T_int8, 751 AggregateInfo: agg.AggregateAnyValue, 752 }, 753 { 754 Index: 5, 755 Args: []types.T{types.T_int16}, 756 ReturnTyp: types.T_int16, 757 AggregateInfo: agg.AggregateAnyValue, 758 }, 759 { 760 Index: 6, 761 Args: []types.T{types.T_int32}, 762 ReturnTyp: types.T_int32, 763 AggregateInfo: agg.AggregateAnyValue, 764 }, 765 { 766 Index: 7, 767 Args: []types.T{types.T_int64}, 768 ReturnTyp: types.T_int64, 769 AggregateInfo: agg.AggregateAnyValue, 770 }, 771 { 772 Index: 8, 773 Args: []types.T{types.T_float32}, 774 ReturnTyp: types.T_float32, 775 AggregateInfo: agg.AggregateAnyValue, 776 }, 777 { 778 Index: 9, 779 Args: []types.T{types.T_float64}, 780 ReturnTyp: types.T_float64, 781 AggregateInfo: agg.AggregateAnyValue, 782 }, 783 { 784 Index: 10, 785 Args: []types.T{types.T_date}, 786 ReturnTyp: types.T_date, 787 AggregateInfo: agg.AggregateAnyValue, 788 }, 789 { 790 Index: 11, 791 Args: []types.T{types.T_datetime}, 792 ReturnTyp: types.T_datetime, 793 AggregateInfo: agg.AggregateAnyValue, 794 }, 795 { 796 Index: 12, 797 Args: []types.T{types.T_decimal64}, 798 ReturnTyp: types.T_decimal64, 799 AggregateInfo: agg.AggregateAnyValue, 800 }, 801 { 802 Index: 13, 803 Args: []types.T{types.T_decimal128}, 804 ReturnTyp: types.T_decimal128, 805 AggregateInfo: agg.AggregateAnyValue, 806 }, 807 { 808 Index: 14, 809 Args: []types.T{types.T_bool}, 810 ReturnTyp: types.T_bool, 811 AggregateInfo: agg.AggregateAnyValue, 812 }, 813 { 814 Index: 15, 815 Args: []types.T{types.T_char}, 816 ReturnTyp: types.T_char, 817 AggregateInfo: agg.AggregateAnyValue, 818 }, 819 { 820 Index: 16, 821 Args: []types.T{types.T_varchar}, 822 ReturnTyp: types.T_varchar, 823 AggregateInfo: agg.AggregateAnyValue, 824 }, 825 { 826 Index: 17, 827 Args: []types.T{types.T_timestamp}, 828 ReturnTyp: types.T_timestamp, 829 AggregateInfo: agg.AggregateAnyValue, 830 }, 831 { 832 Index: 18, 833 Args: []types.T{types.T_blob}, 834 ReturnTyp: types.T_blob, 835 AggregateInfo: agg.AggregateAnyValue, 836 }, 837 { 838 Index: 19, 839 Args: []types.T{types.T_uuid}, 840 ReturnTyp: types.T_uuid, 841 AggregateInfo: agg.AggregateAnyValue, 842 }, 843 { 844 Index: 20, 845 Args: []types.T{types.T_text}, 846 ReturnTyp: types.T_text, 847 AggregateInfo: agg.AggregateAnyValue, 848 }, 849 { 850 Index: 21, 851 Args: []types.T{types.T_time}, 852 ReturnTyp: types.T_time, 853 AggregateInfo: agg.AggregateAnyValue, 854 }, 855 }, 856 }, 857 MEDIAN: { 858 Id: ANY_VALUE, 859 Flag: plan.Function_AGG, 860 Layout: STANDARD_FUNCTION, 861 TypeCheckFn: generalTypeCheckForUnaryAggregate, 862 Overloads: []Function{ 863 { 864 Index: 0, 865 Args: []types.T{types.T_uint8}, 866 ReturnTyp: types.T_float64, 867 AggregateInfo: agg.AggregateMedian, 868 }, 869 { 870 Index: 1, 871 Args: []types.T{types.T_uint16}, 872 ReturnTyp: types.T_float64, 873 AggregateInfo: agg.AggregateMedian, 874 }, 875 { 876 Index: 2, 877 Args: []types.T{types.T_uint32}, 878 ReturnTyp: types.T_float64, 879 AggregateInfo: agg.AggregateMedian, 880 }, 881 { 882 Index: 3, 883 Args: []types.T{types.T_uint64}, 884 ReturnTyp: types.T_float64, 885 AggregateInfo: agg.AggregateMedian, 886 }, 887 { 888 Index: 4, 889 Args: []types.T{types.T_int8}, 890 ReturnTyp: types.T_float64, 891 AggregateInfo: agg.AggregateMedian, 892 }, 893 { 894 Index: 5, 895 Args: []types.T{types.T_int16}, 896 ReturnTyp: types.T_float64, 897 AggregateInfo: agg.AggregateMedian, 898 }, 899 { 900 Index: 6, 901 Args: []types.T{types.T_int32}, 902 ReturnTyp: types.T_float64, 903 AggregateInfo: agg.AggregateMedian, 904 }, 905 { 906 Index: 7, 907 Args: []types.T{types.T_int64}, 908 ReturnTyp: types.T_float64, 909 AggregateInfo: agg.AggregateMedian, 910 }, 911 { 912 Index: 8, 913 Args: []types.T{types.T_float32}, 914 ReturnTyp: types.T_float64, 915 AggregateInfo: agg.AggregateMedian, 916 }, 917 { 918 Index: 9, 919 Args: []types.T{types.T_float64}, 920 ReturnTyp: types.T_float64, 921 AggregateInfo: agg.AggregateMedian, 922 }, 923 { 924 Index: 10, 925 Args: []types.T{types.T_decimal64}, 926 ReturnTyp: types.T_decimal128, 927 AggregateInfo: agg.AggregateMedian, 928 }, 929 { 930 Index: 11, 931 Args: []types.T{types.T_decimal128}, 932 ReturnTyp: types.T_decimal128, 933 AggregateInfo: agg.AggregateMedian, 934 }, 935 }, 936 }, 937 }