summaryrefslogtreecommitdiff
path: root/tests/udf_test.res
blob: 66634e13616d79833c4afd4b0cdad03b86a0d16b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
--------------
CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so"
--------------

Query OK, 0 rows affected

--------------
CREATE FUNCTION myfunc_double RETURNS REAL SONAME "udf_example.so"
--------------

Query OK, 0 rows affected

--------------
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "udf_example.so"
--------------

Query OK, 0 rows affected

--------------
CREATE FUNCTION lookup RETURNS STRING SONAME "udf_example.so"
--------------

Query OK, 0 rows affected

--------------
CREATE FUNCTION reverse_lookup RETURNS STRING SONAME "udf_example.so"
--------------

Query OK, 0 rows affected

--------------
CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "udf_example.so"
--------------

Query OK, 0 rows affected

--------------
select metaphon("hello")
--------------

metaphon("hello")
HL
1 row in set

--------------
select myfunc_double("hello","world")
--------------

myfunc_double("hello","world")
108.40
1 row in set

--------------
select myfunc_int(1,2,3),myfunc_int("1","11","111")
--------------

myfunc_int(1,2,3)	myfunc_int("1","11","111")
6	6
1 row in set

--------------
select lookup("localhost")
--------------

lookup("localhost")
127.0.0.1
1 row in set

--------------
select reverse_lookup("127.0.0.1")
--------------

reverse_lookup("127.0.0.1")
localhost
1 row in set

--------------
create temporary table t1 (a int,b double)
--------------

Query OK, 0 rows affected

--------------
insert into t1 values (1,5),(1,4),(2,8),(3,9),(4,11)
--------------

Query OK, 5 rows affected
Records: 0  Duplicates: 5  Warnings: 0

--------------
select avgcost(a,b) from t1
--------------

avgcost(a,b)
8.7273
1 row in set

--------------
select avgcost(a,b) from t1 group by a
--------------

avgcost(a,b)
4.5000
8.0000
9.0000
11.0000
4 rows in set

--------------
drop table t1
--------------

Query OK, 0 rows affected

--------------
DROP FUNCTION metaphon
--------------

Query OK, 0 rows affected

--------------
DROP FUNCTION myfunc_double
--------------

Query OK, 0 rows affected

--------------
DROP FUNCTION myfunc_int
--------------

Query OK, 0 rows affected

--------------
DROP FUNCTION lookup
--------------

Query OK, 0 rows affected

--------------
DROP FUNCTION reverse_lookup
--------------

Query OK, 0 rows affected

--------------
DROP FUNCTION avgcost
--------------

Query OK, 0 rows affected

Bye