sanity
sanity

Reputation: 35772

How does Apache Cassandra do aggregate operations?

I'm fairly new to Apache Cassandra and nosql in general.

In SQL I can do aggregate operations like:

SELECT 
  country, sum(age) / count(*) AS averageAge 
FROM people 
GROUP BY country;

This is nice because it is calculated within the DB, rather than having to move every row in the 'people' table into the client layer to do the calculation.

Is this possible in Apache Cassandra? How?

Upvotes: 10

Views: 10674

Answers (3)

Kiran
Kiran

Reputation: 1

Current version of Cassandra do not support SUM(). Only count(*) is supported.

Upvotes: 0

Sagar V
Sagar V

Reputation: 1926

Cassandra is primarily a mechanism that supports fast writes and look-ups. There is no support for calculations like aggregates in SQL since it is not designed for that. I would suggest reading of popular Cassandra use-cases to get a better insight :) I have bookmarked some articles on my delicious page. Here is the link:

http://delicious.com/vibhutesagar/cassandra

Upvotes: 9

Schildmeijer
Schildmeijer

Reputation: 20946

Using SliceRange could be thought of as Cassandra's version of LIMIT and ORDER BY.

GROUP BY, COUNT and SUM is not supported out of the box.

Taking a look at the API page from the wiki is a good start.

Upvotes: 2

Related Questions