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

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

问题描述

我正在尝试改造一个 SQL 数据库 Cassandra,以便我可以找到与 SQL 查询等效的 Cassandra.我使用 CQL 3 和 Cassandra v1.2.我在 cassandra 中对 db 设计进行了建模,使其支持 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'

这对我过去几天的工作来说就像是一个炫耀.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 上的配置单元层可能会使这些查询工作.我只是想知道这是否是 Cassandra 支持此类查询的唯一方法..?请建议任何其他可能的方法..

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.

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

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