MAX(),DISTINCT和Cassandra中的group by [英] MAX(), DISTINCT and group by in Cassandra

查看:1852
本文介绍了MAX(),DISTINCT和Cassandra中的group by的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重塑一个SQL数据库Cassandra,这样,我可以找到Cassandra等效的SQL查询。我使用CQL 3和Cassandra v1.2。我在cassandra中建模数据库设计,以便它支持order by子句和非规范化表来支持连接操作。然而,我在海上,当涉及到DISTINCT,SUM()和GROUPBY等价

I am trying to remodel a SQL database Cassandra such that, I can find the Cassandra equivalent for the SQL queries. I use CQL 3 and Cassandra v1.2. I modeled the db design in cassandra so that it supports the order by clauses and denormalized tables to support the join operation. However I am at sea when it comes to DISTINCT, SUM() and GROUPBY equvalents

SELECT a1,MAX(b1) FROM demo1 group by a1.
SELECT DISTINCT (a2) FROM demo2 where b2='sea'
SELECT sum(a3), sum(b3) from demo3 where c3='water' and d3='ocean'

这就像一个showstopper过去几天我的工作。在Cassandra中有一种方法,我可以建模数据库模式来支持这些类型的查询?我不能想到在Cassandra的任何方式。如何使用Cassandra实现这些查询?

This is like a showstopper to my work for past couple of days. Is there a way in Cassandra, that I can model the db schema to support queries of these kind? I cant think of any way in Cassandra . How are such queries be implemented using Cassandra?

我读到Cassandra上的hive层可能会使这些查询工作。我只是想知道,这是这样的查询可以支持Cassandra的唯一方法..? Pls建议任何其他可能的方法。

I read that a hive layer over Cassandra can possibly make these queries work. I am just wondering if that is the only way that such queries can be supported in Cassandra..? Pls advise on any other possible methods..

推荐答案

Cassandra不支持这样的操作。你可以使用顶部的Hive或者Acunu的一个(非免费)产品,它可以做你所需要的。

Cassandra doesn't support operations like this. You can use something like Hive on top or there's a (non-free) product from Acunu that may do what you need.

另一个解决方案是自己做工作。例如,您可以通过读取某些行中的所有数据并进行求和来求和。或者保持Cassandra计数器即时增加。

The other solution is to do the work yourself. For example, you can sum things by reading in all the data from certain rows and summing. Or maintain a Cassandra counter to increment on the fly.

这篇关于MAX(),DISTINCT和Cassandra中的group by的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆