Skip to content
Advertisement

Cassandra UDF: getting error on checking null values


I wrote an UDF like the below:
CREATE FUNCTION myspace.getValue(lng bigint, dbl double, etc double) RETURNS NULL ON NULL INPUT RETURNS double LANGUAGE java AS 'if (lng != null) {return (double)lng;} else if (dbl != null) { return dbl;} else return etc;';

And I get this error:

InvalidRequest: Error from server: code=2200 [Invalid query] message=”Java source compilation failed:
Line 1: The operator != is undefined for the argument type(s) long, null
Line 1: The operator != is undefined for the argument type(s) double, null”

While in manuals these comparisons seems ok (e.g. here). I am using Cassandra 4.0.3 (through its docker image).

Advertisement

Answer

I found the problem. I changed RETURNS NULL ON NULL INPUT to CALLED ON NULL INPUT and it is ok now and works as I expect 🙂

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement