github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/function/udf.result (about)

     1  create database udf_first;
     2  create database udf_second;
     3  use udf_first;
     4  create table tbl1 (
     5  id int,
     6  test_val int
     7  );
     8  create table tbl2 (
     9  id int,
    10  test_val int
    11  );
    12  insert into tbl1(id, test_val) values (1, 10);
    13  insert into tbl1(id, test_val) values (2, 11);
    14  insert into tbl1(id, test_val) values (3, 12);
    15  insert into tbl1(id, test_val) values (4, 13);
    16  insert into tbl2(id, test_val) values (1, 100);
    17  insert into tbl2(id, test_val) values (2, 200);
    18  insert into tbl2(id, test_val) values (3, 300);
    19  insert into tbl2(id, test_val) values (4, 400);
    20  use udf_first;
    21  create function helloworld () returns int language sql as 'select id from tbl1 limit 1';
    22  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'helloworld';
    23  args    rettype    language    db
    24  {}    int    sql    udf_first
    25  use udf_first;
    26  create function helloworld () returns int language sql as 'select id from tbl1 limit 1';
    27  function helloworld already exists
    28  use udf_first;
    29  create function twosum (x int, y int) returns int language sql as 'select $1 + $2' ;
    30  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'twosum';
    31  args    rettype    language    db
    32  {"x":"int","y":"int"}    int    sql    udf_first
    33  create function twosum (x float, y float) returns float language sql as 'select $1 + $2' ;
    34  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'twosum';
    35  args    rettype    language    db
    36  {"x":"int","y":"int"}    int    sql    udf_first
    37  {"x":"float","y":"float"}    float    sql    udf_first
    38  create function twosum (x int) returns int language sql as 'select $1 + 10' ;
    39  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'twosum';
    40  args    rettype    language    db
    41  {"x":"int","y":"int"}    int    sql    udf_first
    42  {"x":"float","y":"float"}    float    sql    udf_first
    43  {"x":"int"}    int    sql    udf_first
    44  use udf_first;
    45  create function udf_second.helloworld () returns int language sql as 'select id from test_table limit 1';
    46  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'helloworld' and db = 'udf_second';
    47  args    rettype    language    db
    48  {}    int    sql    udf_second
    49  use udf_first;
    50  create function mysum(s1 int, s2 int) returns int language sql as '$1 + $2';
    51  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'mysum' and db = 'udf_first';
    52  args    rettype    language    db
    53  {"s1":"int","s2":"int"}    int    sql    udf_first
    54  use udf_first;
    55  create function mysumtable(x int) returns int language sql as 'select mysum(test_val, id) from tbl1 where id = $1';
    56  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'mysumtable' and db = 'udf_first';
    57  args    rettype    language    db
    58  {"x":"int"}    int    sql    udf_first
    59  use udf_first;
    60  select helloworld();
    61  helloworld()
    62  1
    63  use udf_first;
    64  select helloworld(1);
    65  invalid argument helloworld function have invalid input args length, bad value 1
    66  use udf_first;
    67  select twosum(1, 2);
    68  twosum(1, 2)
    69  3
    70  use udf_first;
    71  select twosum(1.1, 2.2);
    72  twosum(1.1, 2.2)
    73  3.3
    74  use udf_first;
    75  select twomult(1.1, 2.2);
    76  not supported: function or operator 'twomult'
    77  use udf_first;
    78  select mysum(id, test_val) from tbl1 where id > 1;
    79  mysum(id, test_val)
    80  13
    81  15
    82  17
    83  use udf_first;
    84  select mysum(tbl1.test_val, tbl2.test_val) from tbl1, tbl2 where tbl1.id = tbl2.id;
    85  mysum(tbl1.test_val, tbl2.test_val)
    86  110
    87  211
    88  312
    89  413
    90  use udf_first;
    91  select mysumtable(id) from tbl2;
    92  mysumtable(id)
    93  11
    94  13
    95  15
    96  17
    97  use udf_first;
    98  drop function helloworld ();
    99  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'helloworld' and db = 'udf_first';
   100  args    rettype    language    db
   101  drop function twosum (int, int);
   102  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'twosum';
   103  args    rettype    language    db
   104  {"x":"float","y":"float"}    float    sql    udf_first
   105  {"x":"int"}    int    sql    udf_first
   106  drop function twosum (int);
   107  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'twosum';
   108  args    rettype    language    db
   109  {"x":"float","y":"float"}    float    sql    udf_first
   110  drop function twosum (float, float);
   111  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'twosum';
   112  args    rettype    language    db
   113  use udf_first;
   114  drop function udf_second.helloworld ();
   115  select args, rettype, language, db from mo_catalog.mo_user_defined_function where name = 'helloworld' and db = 'udf_second';
   116  args    rettype    language    db
   117  use udf_second;
   118  drop function helloworld();
   119  function helloworld doesn't exist