19
19
import com .google .common .collect .HashMultimap ;
20
20
import com .google .common .collect .Multimap ;
21
21
import io .dingodb .exec .fun .AutoIncrementFun ;
22
- import io .dingodb .exec .fun .DingoFunFactory ;
23
22
import io .dingodb .exec .fun .mysql .GlobalVariableFun ;
24
23
import io .dingodb .exec .fun .mysql .VersionFun ;
25
- import io .dingodb .exec .fun .number .FormatFun ;
26
- import io .dingodb .exec .fun .number .PowFun ;
27
- import io .dingodb .exec .fun .string .ConcatFun ;
28
- import io .dingodb .exec .fun .string .LTrimFun ;
29
- import io .dingodb .exec .fun .string .LeftFun ;
30
- import io .dingodb .exec .fun .string .LocateFun ;
31
- import io .dingodb .exec .fun .string .MidFun ;
32
- import io .dingodb .exec .fun .string .RTrimFun ;
33
- import io .dingodb .exec .fun .string .RepeatFun ;
34
- import io .dingodb .exec .fun .string .ReverseFun ;
35
- import io .dingodb .exec .fun .string .RightFun ;
36
- import io .dingodb .exec .fun .time .DateDiffFun ;
24
+ import io .dingodb .exec .fun .special .ThrowFun ;
37
25
import io .dingodb .exec .fun .vector .VectorCosineDistanceFun ;
38
- import io .dingodb .exec .fun .vector .VectorDistanceFun ;
39
26
import io .dingodb .exec .fun .vector .VectorIPDistanceFun ;
40
27
import io .dingodb .exec .fun .vector .VectorImageFun ;
41
28
import io .dingodb .exec .fun .vector .VectorL2DistanceFun ;
42
29
import io .dingodb .exec .fun .vector .VectorTextFun ;
30
+ import io .dingodb .expr .runtime .op .mathematical .PowFunFactory ;
31
+ import io .dingodb .expr .runtime .op .string .ConcatFunFactory ;
32
+ import io .dingodb .expr .runtime .op .string .LTrim1FunFactory ;
33
+ import io .dingodb .expr .runtime .op .string .LeftFunFactory ;
34
+ import io .dingodb .expr .runtime .op .string .Locate2FunFactory ;
35
+ import io .dingodb .expr .runtime .op .string .Mid2FunFactory ;
36
+ import io .dingodb .expr .runtime .op .string .NumberFormatFunFactory ;
37
+ import io .dingodb .expr .runtime .op .string .RTrim1FunFactory ;
38
+ import io .dingodb .expr .runtime .op .string .RepeatFunFactory ;
39
+ import io .dingodb .expr .runtime .op .string .ReverseFunFactory ;
40
+ import io .dingodb .expr .runtime .op .string .RightFunFactory ;
41
+ import io .dingodb .expr .runtime .op .time .DateDiffFunFactory ;
42
+ import io .dingodb .expr .runtime .op .time .DateFormat1FunFactory ;
43
+ import io .dingodb .expr .runtime .op .time .FromUnixTimeFunFactory ;
44
+ import io .dingodb .expr .runtime .op .time .TimeFormat1FunFactory ;
45
+ import io .dingodb .expr .runtime .op .time .TimestampFormat1FunFactory ;
46
+ import io .dingodb .expr .runtime .op .time .UnixTimestamp1FunFactory ;
43
47
import lombok .extern .slf4j .Slf4j ;
44
48
import org .apache .calcite .sql .SqlFunction ;
45
49
import org .apache .calcite .sql .SqlFunctionCategory ;
@@ -95,51 +99,51 @@ private void init() {
95
99
96
100
// number
97
101
registerFunction (
98
- FormatFun .NAME ,
102
+ NumberFormatFunFactory .NAME ,
99
103
ReturnTypes .VARCHAR_2000_NULLABLE ,
100
104
DingoInferTypes .DECIMAL ,
101
105
OperandTypes .NUMERIC_NUMERIC ,
102
106
SqlFunctionCategory .STRING
103
107
);
104
108
registerFunction (
105
- PowFun .NAME ,
106
- DingoReturnTypes . DECIMAL_NULLABLE ,
109
+ PowFunFactory .NAME ,
110
+ ReturnTypes . DOUBLE ,
107
111
DingoInferTypes .DOUBLE ,
108
112
OperandTypes .NUMERIC_NUMERIC ,
109
113
SqlFunctionCategory .STRING
110
114
);
111
115
112
116
// string
113
117
registerFunction (
114
- ConcatFun .NAME ,
118
+ ConcatFunFactory .NAME ,
115
119
ReturnTypes .VARCHAR_2000_NULLABLE ,
116
120
InferTypes .VARCHAR_1024 ,
117
121
OperandTypes .STRING_STRING ,
118
122
SqlFunctionCategory .STRING
119
123
);
120
124
registerFunction (
121
- LeftFun .NAME ,
125
+ LeftFunFactory .NAME ,
122
126
ReturnTypes .VARCHAR_2000_NULLABLE ,
123
127
DingoInferTypes .VARCHAR1024_INTEGER ,
124
128
family (SqlTypeFamily .STRING , SqlTypeFamily .NUMERIC ),
125
129
SqlFunctionCategory .STRING
126
130
);
127
131
registerFunction (
128
- LocateFun .NAME ,
132
+ Locate2FunFactory .NAME ,
129
133
ReturnTypes .INTEGER_NULLABLE ,
130
134
InferTypes .VARCHAR_1024 ,
131
135
OperandTypes .STRING_STRING ,
132
136
SqlFunctionCategory .NUMERIC
133
137
);
134
138
registerFunction (
135
- LTrimFun .NAME ,
139
+ LTrim1FunFactory .NAME ,
136
140
ReturnTypes .VARCHAR_2000_NULLABLE ,
137
141
InferTypes .VARCHAR_1024 ,
138
142
OperandTypes .STRING ,
139
143
SqlFunctionCategory .STRING
140
144
);
141
145
registerFunction (
142
- MidFun .NAME ,
146
+ Mid2FunFactory .NAME ,
143
147
ReturnTypes .VARCHAR_2000_NULLABLE ,
144
148
DingoInferTypes .VARCHAR1024_INTEGER_INTEGER ,
145
149
OperandTypes .or (
@@ -149,28 +153,28 @@ private void init() {
149
153
SqlFunctionCategory .STRING
150
154
);
151
155
registerFunction (
152
- RepeatFun .NAME ,
156
+ RepeatFunFactory .NAME ,
153
157
ReturnTypes .VARCHAR_2000_NULLABLE ,
154
158
DingoInferTypes .VARCHAR1024_INTEGER ,
155
159
family (SqlTypeFamily .STRING , SqlTypeFamily .NUMERIC ),
156
160
SqlFunctionCategory .STRING
157
161
);
158
162
registerFunction (
159
- ReverseFun .NAME ,
163
+ ReverseFunFactory .NAME ,
160
164
ReturnTypes .VARCHAR_2000_NULLABLE ,
161
165
InferTypes .VARCHAR_1024 ,
162
166
OperandTypes .STRING ,
163
167
SqlFunctionCategory .STRING
164
168
);
165
169
registerFunction (
166
- RightFun .NAME ,
170
+ RightFunFactory .NAME ,
167
171
ReturnTypes .VARCHAR_2000_NULLABLE ,
168
172
DingoInferTypes .VARCHAR1024_INTEGER ,
169
173
family (SqlTypeFamily .STRING , SqlTypeFamily .NUMERIC ),
170
174
SqlFunctionCategory .STRING
171
175
);
172
176
registerFunction (
173
- RTrimFun .NAME ,
177
+ RTrim1FunFactory .NAME ,
174
178
ReturnTypes .VARCHAR_2000_NULLABLE ,
175
179
InferTypes .VARCHAR_1024 ,
176
180
OperandTypes .STRING ,
@@ -179,14 +183,14 @@ private void init() {
179
183
180
184
// time
181
185
registerFunction (
182
- DingoFunFactory . FROM_UNIXTIME ,
186
+ FromUnixTimeFunFactory . NAME ,
183
187
ReturnTypes .TIMESTAMP ,
184
188
InferTypes .VARCHAR_1024 ,
185
189
OperandTypes .NUMERIC ,
186
190
SqlFunctionCategory .STRING
187
191
);
188
192
registerFunction (
189
- DingoFunFactory . UNIX_TIMESTAMP ,
193
+ UnixTimestamp1FunFactory . NAME ,
190
194
ReturnTypes .BIGINT ,
191
195
DingoInferTypes .TIMESTAMP ,
192
196
OperandTypes .or (
@@ -197,7 +201,7 @@ private void init() {
197
201
SqlFunctionCategory .NUMERIC
198
202
);
199
203
registerFunction (
200
- DingoFunFactory . DATE_FORMAT ,
204
+ DateFormat1FunFactory . NAME ,
201
205
ReturnTypes .VARCHAR_2000 ,
202
206
DingoInferTypes .DATE_VARCHAR1024 ,
203
207
// Why not `OperandTypes.family(ImmutableList.of(SqlTypeFamily.DATE, SqlTypeFamily.STRING), i -> i == 1)`?
@@ -209,7 +213,7 @@ private void init() {
209
213
SqlFunctionCategory .STRING
210
214
);
211
215
registerFunction (
212
- DingoFunFactory . TIME_FORMAT ,
216
+ TimeFormat1FunFactory . NAME ,
213
217
ReturnTypes .VARCHAR_2000 ,
214
218
DingoInferTypes .TIME_VARCHAR1024 ,
215
219
OperandTypes .or (
@@ -219,7 +223,7 @@ private void init() {
219
223
SqlFunctionCategory .STRING
220
224
);
221
225
registerFunction (
222
- DingoFunFactory . TIMESTAMP_FORMAT ,
226
+ TimestampFormat1FunFactory . NAME ,
223
227
ReturnTypes .VARCHAR_2000 ,
224
228
DingoInferTypes .TIMESTAMP_VARCHAR1024 ,
225
229
OperandTypes .or (
@@ -231,7 +235,7 @@ private void init() {
231
235
SqlFunctionCategory .STRING
232
236
);
233
237
registerFunction (
234
- DateDiffFun .NAME ,
238
+ DateDiffFunFactory .NAME ,
235
239
ReturnTypes .BIGINT ,
236
240
DingoInferTypes .DATE_DATE ,
237
241
family (SqlTypeFamily .DATE , SqlTypeFamily .DATE ),
@@ -240,10 +244,10 @@ private void init() {
240
244
241
245
// special
242
246
registerFunction (
243
- DingoFunFactory . THROW ,
247
+ ThrowFun . NAME ,
244
248
ReturnTypes .VARCHAR_2000_NULLABLE ,
245
- InferTypes . VARCHAR_1024 ,
246
- OperandTypes .STRING ,
249
+ null ,
250
+ OperandTypes .NILADIC ,
247
251
SqlFunctionCategory .STRING
248
252
);
249
253
registerFunction (
@@ -295,13 +299,6 @@ private void init() {
295
299
family (SqlTypeFamily .ARRAY , SqlTypeFamily .ARRAY ),
296
300
SqlFunctionCategory .NUMERIC
297
301
);
298
- registerFunction (
299
- VectorDistanceFun .NAME ,
300
- FLOAT ,
301
- DingoInferTypes .FLOAT ,
302
- family (SqlTypeFamily .ARRAY , SqlTypeFamily .ARRAY ),
303
- SqlFunctionCategory .NUMERIC
304
- );
305
302
registerFunction (
306
303
VersionFun .NAME ,
307
304
ReturnTypes .VARCHAR_2000 ,
0 commit comments