Spierki
Spierki

Reputation: 241

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

Upvotes: 7

Views: 7446

Answers (2)

CommonSenseCode
CommonSenseCode

Reputation: 25428

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

Upvotes: 1

Mikhail Stepura
Mikhail Stepura

Reputation: 3374

Aggregate functions will be available as part of Cassandra 3.0

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

Upvotes: 4

Related Questions