Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra aggregation

I have a Cassandra cluster with 4 table and data inside.

I want to make request with aggregation function ( sum, max ...) but I've read here that it's impossible : http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/cql_function_r.html

Is there a way to make sum , average, group by, without buying the enterprise version, can I use presto , or other solutions?

Thanks

like image 711
Spierki Avatar asked Nov 10 '14 14:11

Spierki


2 Answers

Aggregate functions will be available as part of Cassandra 3.0

https://issues.apache.org/jira/browse/CASSANDRA-4914

like image 168
Mikhail Stepura Avatar answered Oct 06 '22 11:10

Mikhail Stepura


Sure it does:

Native aggregates

Count

The count function can be used to count the rows returned by a query. Example:

SELECT COUNT (*) FROM plays;
SELECT COUNT (1) FROM plays;

It also can be used to count the non null value of a given column:

SELECT COUNT (scores) FROM plays;

Max and Min

The max and min functions can be used to compute the maximum and the minimum value returned by a query for a given column. For instance:

SELECT MIN (players), MAX (players) FROM plays WHERE game = 'quake';

Sum

The sum function can be used to sum up all the values returned by a query for a given column. For instance:

SELECT SUM (players) FROM plays;

Avg

The avg function can be used to compute the average of all the values returned by a query for a given column. For instance:

SELECT AVG (players) FROM plays;

You can also create your own aggregates, more documentation on aggregates here: http://cassandra.apache.org/doc/latest/cql/functions.html?highlight=aggregate

like image 44
CommonSenseCode Avatar answered Oct 06 '22 12:10

CommonSenseCode