@@ -40,8 +40,15 @@ public static void AddComparisonFunctions(IFunctionsRegister functionsRegister)
40
40
functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . Equal , typeof ( BuiltInComparisonFunctions ) , nameof ( EqualImplementation ) ) ;
41
41
functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . NotEqual , typeof ( BuiltInComparisonFunctions ) , nameof ( NotEqualImplementation ) ) ;
42
42
functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . GreaterThan , typeof ( BuiltInComparisonFunctions ) , nameof ( GreaterThanImplementation ) ) ;
43
+ functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . GreaterThanOrEqual , typeof ( BuiltInComparisonFunctions ) , nameof ( GreaterThanOrEqualImplementation ) ) ;
44
+ functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . LessThan , typeof ( BuiltInComparisonFunctions ) , nameof ( LessThanImplementation ) ) ;
45
+ functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . LessThanOrEqual , typeof ( BuiltInComparisonFunctions ) , nameof ( LessThanOrEqualImplementation ) ) ;
43
46
functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . IsNull , typeof ( BuiltInComparisonFunctions ) , nameof ( IsNullImplementation ) ) ;
47
+ functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . IsNotNull , typeof ( BuiltInComparisonFunctions ) , nameof ( IsNotNullImplementation ) ) ;
44
48
functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . Between , typeof ( BuiltInComparisonFunctions ) , nameof ( BetweenImplementation ) ) ;
49
+ functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . IsFinite , typeof ( BuiltInComparisonFunctions ) , nameof ( IsFiniteImplementation ) ) ;
50
+ functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . isInfinite , typeof ( BuiltInComparisonFunctions ) , nameof ( IsInfiniteImplementation ) ) ;
51
+ functionsRegister . RegisterScalarMethod ( FunctionsComparison . Uri , FunctionsComparison . IsNan , typeof ( BuiltInComparisonFunctions ) , nameof ( IsNanImplementation ) ) ;
45
52
46
53
functionsRegister . RegisterColumnScalarFunction ( FunctionsComparison . Uri , FunctionsComparison . Coalesce ,
47
54
( scalarFunction , parametersInfo , visitor ) =>
@@ -143,6 +150,78 @@ private static IDataValue GreaterThanImplementation<T1, T2>(in T1 x, in T2 y, in
143
150
}
144
151
}
145
152
153
+ private static IDataValue GreaterThanOrEqualImplementation < T1 , T2 > ( in T1 x , in T2 y , in DataValueContainer result )
154
+ where T1 : IDataValue
155
+ where T2 : IDataValue
156
+ {
157
+ // If either is null, return null
158
+ if ( x . IsNull || y . IsNull )
159
+ {
160
+ result . _type = ArrowTypeId . Null ;
161
+ return result ;
162
+ }
163
+ else if ( DataValueComparer . CompareTo ( x , y ) >= 0 )
164
+ {
165
+ result . _type = ArrowTypeId . Boolean ;
166
+ result . _boolValue = new BoolValue ( true ) ;
167
+ return result ;
168
+ }
169
+ else
170
+ {
171
+ result . _type = ArrowTypeId . Boolean ;
172
+ result . _boolValue = new BoolValue ( false ) ;
173
+ return result ;
174
+ }
175
+ }
176
+
177
+ private static IDataValue LessThanImplementation < T1 , T2 > ( in T1 x , in T2 y , in DataValueContainer result )
178
+ where T1 : IDataValue
179
+ where T2 : IDataValue
180
+ {
181
+ // If either is null, return null
182
+ if ( x . IsNull || y . IsNull )
183
+ {
184
+ result . _type = ArrowTypeId . Null ;
185
+ return result ;
186
+ }
187
+ else if ( DataValueComparer . CompareTo ( x , y ) < 0 )
188
+ {
189
+ result . _type = ArrowTypeId . Boolean ;
190
+ result . _boolValue = new BoolValue ( true ) ;
191
+ return result ;
192
+ }
193
+ else
194
+ {
195
+ result . _type = ArrowTypeId . Boolean ;
196
+ result . _boolValue = new BoolValue ( false ) ;
197
+ return result ;
198
+ }
199
+ }
200
+
201
+ private static IDataValue LessThanOrEqualImplementation < T1 , T2 > ( in T1 x , in T2 y , in DataValueContainer result )
202
+ where T1 : IDataValue
203
+ where T2 : IDataValue
204
+ {
205
+ // If either is null, return null
206
+ if ( x . IsNull || y . IsNull )
207
+ {
208
+ result . _type = ArrowTypeId . Null ;
209
+ return result ;
210
+ }
211
+ else if ( DataValueComparer . CompareTo ( x , y ) <= 0 )
212
+ {
213
+ result . _type = ArrowTypeId . Boolean ;
214
+ result . _boolValue = new BoolValue ( true ) ;
215
+ return result ;
216
+ }
217
+ else
218
+ {
219
+ result . _type = ArrowTypeId . Boolean ;
220
+ result . _boolValue = new BoolValue ( false ) ;
221
+ return result ;
222
+ }
223
+ }
224
+
146
225
private static IDataValue IsNullImplementation < T > ( in T x , in DataValueContainer result )
147
226
where T : IDataValue
148
227
{
@@ -151,11 +230,24 @@ private static IDataValue IsNullImplementation<T>(in T x, in DataValueContainer
151
230
return result ;
152
231
}
153
232
233
+ private static IDataValue IsNotNullImplementation < T > ( in T x , in DataValueContainer result )
234
+ where T : IDataValue
235
+ {
236
+ result . _type = ArrowTypeId . Boolean ;
237
+ result . _boolValue = new BoolValue ( ! x . IsNull ) ;
238
+ return result ;
239
+ }
240
+
154
241
private static IDataValue BetweenImplementation < T1 , T2 , T3 > ( in T1 expr , in T2 low , in T3 high , in DataValueContainer result )
155
242
where T1 : IDataValue
156
243
where T2 : IDataValue
157
244
where T3 : IDataValue
158
245
{
246
+ if ( expr . IsNull || low . IsNull || high . IsNull )
247
+ {
248
+ result . _type = ArrowTypeId . Null ;
249
+ return result ;
250
+ }
159
251
160
252
if ( DataValueComparer . CompareTo ( expr , low ) >= 0 && DataValueComparer . CompareTo ( expr , high ) <= 0 )
161
253
{
@@ -170,5 +262,113 @@ private static IDataValue BetweenImplementation<T1, T2, T3>(in T1 expr, in T2 lo
170
262
return result ;
171
263
}
172
264
}
265
+
266
+ private static IDataValue IsFiniteImplementation < T > ( in T x , in DataValueContainer result )
267
+ where T : IDataValue
268
+ {
269
+ if ( x . Type == ArrowTypeId . Double )
270
+ {
271
+ var val = x . AsDouble ;
272
+ if ( val == double . PositiveInfinity || val == double . NegativeInfinity || double . IsNaN ( val ) )
273
+ {
274
+ result . _type = ArrowTypeId . Boolean ;
275
+ result . _boolValue = new BoolValue ( false ) ;
276
+ return result ;
277
+ }
278
+ else
279
+ {
280
+ result . _type = ArrowTypeId . Boolean ;
281
+ result . _boolValue = new BoolValue ( true ) ;
282
+ return result ;
283
+ }
284
+ }
285
+ else if ( x . Type == ArrowTypeId . Int64 )
286
+ {
287
+ result . _type = ArrowTypeId . Boolean ;
288
+ result . _boolValue = new BoolValue ( true ) ;
289
+ return result ;
290
+ }
291
+ else if ( x . Type == ArrowTypeId . Decimal128 )
292
+ {
293
+ result . _type = ArrowTypeId . Boolean ;
294
+ result . _boolValue = new BoolValue ( true ) ;
295
+ return result ;
296
+ }
297
+
298
+ result . _type = ArrowTypeId . Null ;
299
+ return result ;
300
+ }
301
+
302
+ private static IDataValue IsInfiniteImplementation < T > ( in T x , in DataValueContainer result )
303
+ where T : IDataValue
304
+ {
305
+ if ( x . Type == ArrowTypeId . Double )
306
+ {
307
+ var val = x . AsDouble ;
308
+ if ( val == double . PositiveInfinity || val == double . NegativeInfinity )
309
+ {
310
+ result . _type = ArrowTypeId . Boolean ;
311
+ result . _boolValue = new BoolValue ( true ) ;
312
+ return result ;
313
+ }
314
+ else
315
+ {
316
+ result . _type = ArrowTypeId . Boolean ;
317
+ result . _boolValue = new BoolValue ( false ) ;
318
+ return result ;
319
+ }
320
+ }
321
+ else if ( x . Type == ArrowTypeId . Int64 )
322
+ {
323
+ result . _type = ArrowTypeId . Boolean ;
324
+ result . _boolValue = new BoolValue ( false ) ;
325
+ return result ;
326
+ }
327
+ else if ( x . Type == ArrowTypeId . Decimal128 )
328
+ {
329
+ result . _type = ArrowTypeId . Boolean ;
330
+ result . _boolValue = new BoolValue ( false ) ;
331
+ return result ;
332
+ }
333
+
334
+ result . _type = ArrowTypeId . Null ;
335
+ return result ;
336
+ }
337
+
338
+ private static IDataValue IsNanImplementation < T > ( in T x , in DataValueContainer result )
339
+ where T : IDataValue
340
+ {
341
+ if ( x . Type == ArrowTypeId . Double )
342
+ {
343
+ var val = x . AsDouble ;
344
+ if ( double . IsNaN ( val ) )
345
+ {
346
+ result . _type = ArrowTypeId . Boolean ;
347
+ result . _boolValue = new BoolValue ( true ) ;
348
+ return result ;
349
+ }
350
+ else
351
+ {
352
+ result . _type = ArrowTypeId . Boolean ;
353
+ result . _boolValue = new BoolValue ( false ) ;
354
+ return result ;
355
+ }
356
+ }
357
+ else if ( x . Type == ArrowTypeId . Int64 )
358
+ {
359
+ result . _type = ArrowTypeId . Boolean ;
360
+ result . _boolValue = new BoolValue ( false ) ;
361
+ return result ;
362
+ }
363
+ else if ( x . Type == ArrowTypeId . Decimal128 )
364
+ {
365
+ result . _type = ArrowTypeId . Boolean ;
366
+ result . _boolValue = new BoolValue ( false ) ;
367
+ return result ;
368
+ }
369
+
370
+ result . _type = ArrowTypeId . Null ;
371
+ return result ;
372
+ }
173
373
}
174
374
}
0 commit comments