Cassandra aggregation

泄露秘密 提交于 2019-12-08 21:44:08

问题


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


回答1:


Aggregate functions will be available as part of Cassandra 3.0

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




回答2:


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



来源:https://stackoverflow.com/questions/26845821/cassandra-aggregation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!