2
# For this script to work, you need to compile and install the
6
CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so";
7
CREATE FUNCTION myfunc_double RETURNS REAL SONAME "udf_example.so";
8
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "udf_example.so";
9
CREATE FUNCTION lookup RETURNS STRING SONAME "udf_example.so";
10
CREATE FUNCTION reverse_lookup RETURNS STRING SONAME "udf_example.so";
11
CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "udf_example.so";
12
CREATE FUNCTION myfunc_argument_name RETURNS STRING SONAME "udf_example.so";
14
select metaphon("hello");
15
select myfunc_double("hello","world");
16
select myfunc_int(1,2,3),myfunc_int("1","11","111");
17
select lookup("localhost");
18
select reverse_lookup("127.0.0.1");
20
create temporary table t1 (a int,b double);
21
insert into t1 values (1,5),(1,4),(2,8),(3,9),(4,11);
22
select avgcost(a,b) from t1;
23
select avgcost(a,b) from t1 group by a;
24
select a, myfunc_argument_name(a), myfunc_argument_name(a as b) from t1;
27
DROP FUNCTION metaphon;
28
DROP FUNCTION myfunc_double;
29
DROP FUNCTION myfunc_int;
31
DROP FUNCTION reverse_lookup;
32
DROP FUNCTION avgcost;
33
DROP FUNCTION myfunc_argument_name;