Reputation: 231
I am new in Cassandra. I want to aggregate my columns like SUM()
, MAX()
, etc.
So is there any way like functions or query or something that can help me ?
Upvotes: 1
Views: 2909
Reputation: 9475
The CQL (Cassandra Query Language) built into Cassandra 2.1.6 only supports the count() aggregation function.
So to do aggregation in Cassandra, there are a few options:
Do a query that returns all the rows you want to aggregate, and sum them on the client side in java/python/etc.
Write your application to do aggregation of your data when inserting it into Cassandra, and update the aggregated data as you insert additional data.
Pair Cassandra with a component like Apache spark using the Cassandra Spark Connector. This requires some effort to learn and set up, but offers aggregation functions and many additional analytics features.
Upgrade to Cassandra 2.2.0 (currently available as release candidate 1). A new feature in 2.2 is support for user defined functions. With UDF you can define aggregation functions. See an example here.
Upvotes: 1