Is there a description of the sum function in CQL?

I can easily execute the request from DevCenter:

SELECT sum(count) FROM myTable; 

But I did not find any information about the sum function in cql . He exists? Where did the cassandra team publish a list of functions with the count function and others?

Note

This list of functions does not say anything about count or sum .

+4
source share
2 answers

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 ().

+3
source

Cassandra does not support aggregate functions as part of the CQL standard. But, starting with Cassandra 2.2, you can create your own functions ( UDA ), which will allow you to implement the calculation of the amount.

+1
source

All Articles