我有一个正在运行的 apache-cassandra-2.2.1 并enable_user_defined_functions
设置为true
in cassandra.yml
。我根据这篇文章定义了一个自定义聚合,如下所示:
CREATE FUNCTION sumFunc(current double, candidate double) CALLED ON NULL INPUT RETURNS double LANGUAGE java AS 'if(current == null) return candidate; return current + candidate;'
CREATE AGGREGATE sum(double) SFUNC sumFunc STYPE double INITCOND null;
当我从 CQLSH 控制台调用它时,我看到了超时:
cqlsh:test> SELECT word, sum(frequency) FROM words;
OperationTimedOut: errors={}, last_host=127.0.0.1
我可以成功运行任何其他查询,我也可以从 scala 运行查询(但我没有得到完整的结果集):
CassandraConnector(conf).withSessionDo { session =>
val result: ResultSet = session.execute("SELECT word, SUM(frequency) FROM test.words;")
while(result.isExhausted == false) {
println(result.one)
}
}