Skip to content

Commit f8ac6a3

Browse files
committed
dolphin: Add a subset of math func signatures
1 parent ba125cc commit f8ac6a3

File tree

1 file changed

+162
-37
lines changed

1 file changed

+162
-37
lines changed

internal/engine/dolphin/stdlib.go

Lines changed: 162 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,77 @@ import (
88
func defaultSchema(name string) *catalog.Schema {
99
s := &catalog.Schema{Name: name}
1010
s.Funcs = []*catalog.Function{
11-
1211
{
13-
Name: "ABS",
14-
Args: []*catalog.Argument{},
15-
ReturnType: &ast.TypeName{Name: "any"},
12+
Name: "ABS",
13+
Args: []*catalog.Argument{
14+
{
15+
Type: &ast.TypeName{Name: "tinyint"},
16+
},
17+
},
18+
ReturnType: &ast.TypeName{Name: "tinyint"},
1619
},
1720
{
18-
Name: "ACOS",
19-
Args: []*catalog.Argument{},
20-
ReturnType: &ast.TypeName{Name: "any"},
21+
Name: "ABS",
22+
Args: []*catalog.Argument{
23+
{
24+
Type: &ast.TypeName{Name: "smallint"},
25+
},
26+
},
27+
ReturnType: &ast.TypeName{Name: "smallint"},
28+
},
29+
{
30+
Name: "ABS",
31+
Args: []*catalog.Argument{
32+
{
33+
Type: &ast.TypeName{Name: "mediumint"},
34+
},
35+
},
36+
ReturnType: &ast.TypeName{Name: "mediumint"},
37+
},
38+
{
39+
Name: "ABS",
40+
Args: []*catalog.Argument{
41+
{
42+
Type: &ast.TypeName{Name: "int"},
43+
},
44+
},
45+
ReturnType: &ast.TypeName{Name: "int"},
46+
},
47+
{
48+
Name: "ABS",
49+
Args: []*catalog.Argument{
50+
{
51+
Type: &ast.TypeName{Name: "bigint"},
52+
},
53+
},
54+
ReturnType: &ast.TypeName{Name: "bigint"},
55+
},
56+
{
57+
Name: "ABS",
58+
Args: []*catalog.Argument{
59+
{
60+
Type: &ast.TypeName{Name: "double"},
61+
},
62+
},
63+
ReturnType: &ast.TypeName{Name: "double"},
64+
},
65+
{
66+
Name: "ABS",
67+
Args: []*catalog.Argument{
68+
{
69+
Type: &ast.TypeName{Name: "double precision"},
70+
},
71+
},
72+
ReturnType: &ast.TypeName{Name: "double precision"},
73+
},
74+
{
75+
Name: "ACOS",
76+
Args: []*catalog.Argument{
77+
{
78+
Type: &ast.TypeName{Name: "double precision"},
79+
},
80+
},
81+
ReturnType: &ast.TypeName{Name: "double precision"},
2182
},
2283
{
2384
Name: "ADDDATE",
@@ -50,19 +111,31 @@ func defaultSchema(name string) *catalog.Schema {
50111
ReturnType: &ast.TypeName{Name: "any"},
51112
},
52113
{
53-
Name: "ASIN",
54-
Args: []*catalog.Argument{},
55-
ReturnType: &ast.TypeName{Name: "any"},
114+
Name: "ASIN",
115+
Args: []*catalog.Argument{
116+
{
117+
Type: &ast.TypeName{Name: "double precision"},
118+
},
119+
},
120+
ReturnType: &ast.TypeName{Name: "double precision"},
56121
},
57122
{
58-
Name: "ATAN",
59-
Args: []*catalog.Argument{},
60-
ReturnType: &ast.TypeName{Name: "any"},
123+
Name: "ATAN",
124+
Args: []*catalog.Argument{
125+
{
126+
Type: &ast.TypeName{Name: "double precision"},
127+
},
128+
},
129+
ReturnType: &ast.TypeName{Name: "double precision"},
61130
},
62131
{
63-
Name: "ATAN2",
64-
Args: []*catalog.Argument{},
65-
ReturnType: &ast.TypeName{Name: "any"},
132+
Name: "ATAN2",
133+
Args: []*catalog.Argument{
134+
{
135+
Type: &ast.TypeName{Name: "double precision"},
136+
},
137+
},
138+
ReturnType: &ast.TypeName{Name: "double precision"},
66139
},
67140
{
68141
Name: "AVG",
@@ -115,14 +188,40 @@ func defaultSchema(name string) *catalog.Schema {
115188
ReturnType: &ast.TypeName{Name: "any"},
116189
},
117190
{
118-
Name: "CEIL",
119-
Args: []*catalog.Argument{},
120-
ReturnType: &ast.TypeName{Name: "any"},
191+
Name: "CEIL",
192+
Args: []*catalog.Argument{
193+
{
194+
Type: &ast.TypeName{Name: "int"},
195+
},
196+
},
197+
ReturnType: &ast.TypeName{Name: "int"},
121198
},
122199
{
123-
Name: "CEILING",
124-
Args: []*catalog.Argument{},
125-
ReturnType: &ast.TypeName{Name: "any"},
200+
Name: "CEIL",
201+
Args: []*catalog.Argument{
202+
{
203+
Type: &ast.TypeName{Name: "double precision"},
204+
},
205+
},
206+
ReturnType: &ast.TypeName{Name: "double precision"},
207+
},
208+
{
209+
Name: "CEILING",
210+
Args: []*catalog.Argument{
211+
{
212+
Type: &ast.TypeName{Name: "int"},
213+
},
214+
},
215+
ReturnType: &ast.TypeName{Name: "int"},
216+
},
217+
{
218+
Name: "CEILING",
219+
Args: []*catalog.Argument{
220+
{
221+
Type: &ast.TypeName{Name: "double precision"},
222+
},
223+
},
224+
ReturnType: &ast.TypeName{Name: "double precision"},
126225
},
127226
{
128227
Name: "CHAR",
@@ -180,9 +279,19 @@ func defaultSchema(name string) *catalog.Schema {
180279
ReturnType: &ast.TypeName{Name: "any"},
181280
},
182281
{
183-
Name: "CONV",
184-
Args: []*catalog.Argument{},
185-
ReturnType: &ast.TypeName{Name: "any"},
282+
Name: "CONV",
283+
Args: []*catalog.Argument{
284+
{
285+
Type: &ast.TypeName{Name: "int"},
286+
},
287+
{
288+
Type: &ast.TypeName{Name: "int"},
289+
},
290+
{
291+
Type: &ast.TypeName{Name: "int"},
292+
},
293+
},
294+
ReturnType: &ast.TypeName{Name: "text"},
186295
},
187296
{
188297
Name: "CONVERT",
@@ -195,14 +304,22 @@ func defaultSchema(name string) *catalog.Schema {
195304
ReturnType: &ast.TypeName{Name: "any"},
196305
},
197306
{
198-
Name: "COS",
199-
Args: []*catalog.Argument{},
200-
ReturnType: &ast.TypeName{Name: "any"},
307+
Name: "COS",
308+
Args: []*catalog.Argument{
309+
{
310+
Type: &ast.TypeName{Name: "double precision"},
311+
},
312+
},
313+
ReturnType: &ast.TypeName{Name: "double precision"},
201314
},
202315
{
203-
Name: "COT",
204-
Args: []*catalog.Argument{},
205-
ReturnType: &ast.TypeName{Name: "any"},
316+
Name: "COT",
317+
Args: []*catalog.Argument{
318+
{
319+
Type: &ast.TypeName{Name: "double precision"},
320+
},
321+
},
322+
ReturnType: &ast.TypeName{Name: "double precision"},
206323
},
207324
{
208325
Name: "COUNT",
@@ -219,9 +336,13 @@ func defaultSchema(name string) *catalog.Schema {
219336
ReturnType: &ast.TypeName{Name: "bigint"},
220337
},
221338
{
222-
Name: "CRC32",
223-
Args: []*catalog.Argument{},
224-
ReturnType: &ast.TypeName{Name: "any"},
339+
Name: "CRC32",
340+
Args: []*catalog.Argument{
341+
{
342+
Type: &ast.TypeName{Name: "text"},
343+
},
344+
},
345+
ReturnType: &ast.TypeName{Name: "int"},
225346
},
226347
{
227348
Name: "CUME_DIST",
@@ -344,9 +465,13 @@ func defaultSchema(name string) *catalog.Schema {
344465
ReturnType: &ast.TypeName{Name: "any"},
345466
},
346467
{
347-
Name: "DEGREES",
348-
Args: []*catalog.Argument{},
349-
ReturnType: &ast.TypeName{Name: "any"},
468+
Name: "DEGREES",
469+
Args: []*catalog.Argument{
470+
{
471+
Type: &ast.TypeName{Name: "double precision"},
472+
},
473+
},
474+
ReturnType: &ast.TypeName{Name: "int"},
350475
},
351476
{
352477
Name: "DENSE_RANK",

0 commit comments

Comments
 (0)