简体   繁体   中英

How to return null in hive udf in scala?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM