zeroshade commented on code in PR #135:
URL: https://github.com/apache/arrow-go/pull/135#discussion_r1773677120
##########
arrow/compute/scalar_compare.go:
##########
@@ -134,4 +136,50 @@ func RegisterScalarComparisons(reg FunctionRegistry) {
reg.AddFunction(ltFn, false)
lteFn := makeFlippedCompare("less_equal", gteFn, EmptyFuncDoc)
reg.AddFunction(lteFn, false)
+
+ isOrNotNullKns := kernels.IsNullKernels()
+ isNullFn := &compareFunction{*NewScalarFunction("is_null", Unary(),
EmptyFuncDoc)}
+ if err := isNullFn.AddKernel(isOrNotNullKns[0]); err != nil {
+ panic(err)
+ }
+
+ isNotNullFn := &compareFunction{*NewScalarFunction("is_not_null",
Unary(), EmptyFuncDoc)}
+ if err := isNotNullFn.AddKernel(isOrNotNullKns[1]); err != nil {
+ panic(err)
+ }
+
+ reg.AddFunction(isNullFn, false)
+ reg.AddFunction(isNotNullFn, false)
+
+ reg.AddFunction(NewMetaFunction("is_nan", Unary(), EmptyFuncDoc,
+ func(ctx context.Context, opts FunctionOptions, args ...Datum)
(Datum, error) {
+ switch args[0].Kind() {
+ case KindScalar:
+ arg := args[0].(*ScalarDatum)
+ switch arg.Type() {
+ case arrow.PrimitiveTypes.Float32,
arrow.PrimitiveTypes.Float64:
+ // IEEE 754 says that only NAN
satisfies f != f
+ return CallFunction(ctx, "not_equal",
nil, arg, arg)
+ default:
+ return NewDatum(true), nil
Review Comment:
good catch, i screwed that up. it should be returning a scalar false
##########
arrow/compute/scalar_compare.go:
##########
@@ -134,4 +136,50 @@ func RegisterScalarComparisons(reg FunctionRegistry) {
reg.AddFunction(ltFn, false)
lteFn := makeFlippedCompare("less_equal", gteFn, EmptyFuncDoc)
reg.AddFunction(lteFn, false)
+
+ isOrNotNullKns := kernels.IsNullKernels()
+ isNullFn := &compareFunction{*NewScalarFunction("is_null", Unary(),
EmptyFuncDoc)}
+ if err := isNullFn.AddKernel(isOrNotNullKns[0]); err != nil {
+ panic(err)
+ }
+
+ isNotNullFn := &compareFunction{*NewScalarFunction("is_not_null",
Unary(), EmptyFuncDoc)}
+ if err := isNotNullFn.AddKernel(isOrNotNullKns[1]); err != nil {
+ panic(err)
+ }
+
+ reg.AddFunction(isNullFn, false)
+ reg.AddFunction(isNotNullFn, false)
+
+ reg.AddFunction(NewMetaFunction("is_nan", Unary(), EmptyFuncDoc,
+ func(ctx context.Context, opts FunctionOptions, args ...Datum)
(Datum, error) {
+ switch args[0].Kind() {
Review Comment:
reordered and updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]