I've a running apache-cassandra-2.2.1 with enable_user_defined_functions
set to true
in cassandra.yml
. I've defined a custom aggregation based on this article as follows:
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;
When I call this from CQLSH console I see a timeout:
cqlsh:test> SELECT word, sum(frequency) FROM words;
OperationTimedOut: errors={}, last_host=127.0.0.1
I can successful run any other query, I can also run the query (but I don't get full result set) from scala:
CassandraConnector(conf).withSessionDo { session =>
val result: ResultSet = session.execute("SELECT word, SUM(frequency) FROM test.words;")
while(result.isExhausted == false) {
println(result.one)
}
}