Cassandra UDF:检查零值时出错
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;';
我得到了这个错误:
InvalidRequest:来自服务器的错误:代码= 2200 [无效查询]消息=“ Java源编译失败:
)不确定
第1行:运算符!=对于参数类型长,null
不确定 第1行:操作员!=对于参数类型double,null“
在手册中这些比较似乎还可以(例如master/udfs.cql“ rel =“ nofollow noreferrer”>在这里)。 我正在使用Cassandra 4.0.3(通过其Docker映像)。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现了这个问题。我将
更改为null输入
上的null在null Input
上都可以,现在还可以,我希望:)I found the problem. I changed
RETURNS NULL ON NULL INPUT
toCALLED ON NULL INPUT
and it is ok now and works as I expect :)这确实是一个爪哇问题,而不是卡桑德拉的问题。
double
和长
都是原始的Java数据类型,如果不是初始化的(0l
或0.0D 分别),因此它们不能为
null
。有关更多信息,请参见 Java Primitive Data类型。干杯!
This is really a Java question more than a Cassandra question.
Both
double
andlong
are primitive Java data types and are assigned a default value if not initialised (0L
or0.0d
respectively) so they can't benull
.For more information, see Java Primitive Data Types. Cheers!