The sum () and avg () functions work in Cassandra 2.2 and 3.0-alpha for SELECT statements, but they don't seem to be in the documentation yet.
They should probably be documented in the 2.2 CQL link here . I assume that they will work hard to update the documentation when 3.0 is officially released.
They seem pretty easy to use:
cqlsh:test> CREATE table t1 ( a int, b int, primary key (a)); cqlsh:test> INSERT INTO t1 (a, b) VALUES ( 1, 2); cqlsh:test> INSERT INTO t1 (a, b) VALUES ( 3, 4); cqlsh:test> SELECT sum (b) from t1; system.sum(b) --------------- 6 (1 rows) cqlsh:test> SELECT avg (b) from t1; system.avg(b) --------------- 3
Well, finally, the basic aggregation functions are built in. Now, if someone just implemented the basic associations using an approach similar to Spark, which we will prepare with gas. :)
To answer your question a little more, functions appear in this file (if you download the source code):
src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java
The functions implemented in Cassandra 2.2 are: sum (), avg (), max (), min (), and count ().
source share