How to return null in hive udf in scala?

294 Views Asked by At

I am working on a Hive UDF in Scala

class MyUDF extends UDF {
    def func(a: Double): Double {
        if (cond){ how to return null in this case? }
        else {some double}
    }
}

I tried null.asInstanceOf[Double] but this gives the output as 0. I need a NULL output in hive instead.

Thanks.

1

There are 1 best solutions below

0
Thilo On BEST ANSWER

A Scala Double cannot be null. Can you change the interface to return a java.lang.Double?