星火卡桑德拉连接器 - where子句 [英] Spark Cassandra connector - where clause

查看:113
本文介绍了星火卡桑德拉连接器 - where子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用火花和Datastax公布新的连接器做存储在卡珊德拉的时间序列数据分析的一些

I am trying to do some analytics on time series data stored in cassandra by using spark and the new connector published by Datastax.

在我的架构分区键是米ID,我只希望在细节一串火花的操作,因此,我需要通过仪表ID进行过滤。

In my schema the Partition key is the meter ID and I want to run spark operations only on specifics series, therefore I need to filter by meter ID.

我想,然后跑像查询:从时间序列中选择*其中series_id = X

I would like then to run a query like: Select * from timeseries where series_id = X

我曾尝试这样做,以实现这一点:

I have tried to achieve this by doing:

JavaRDD<CassandraRow> rdd = sc.cassandraTable("test", "timeseries").select(columns).where("series_id = ?",ids).toJavaRDD();

在执行这个code中的查询结果是:

When executing this code the resulting query is:

SELECT "series_id", "timestamp", "value" FROM "timeseries" WHERE token("series_id") > 1059678427073559546 AND token("series_id") <= 1337476147328479245 AND series_id = ? ALLOW FILTERING

(令牌(series_id)> X AND令牌(series_id)&LT; = Y)

一个条款将自动在我的分区键添加,然后矿后追加。这显然​​不工作,我得到一个错误说:series_id不能用,如果它包括一个平等多个关系来限制

A clause is automatically added on my partition key (token("series_id") > X AND token("series_id") <=Y) and then mine is appended after that. This obviously does not work and I get an error saying: "series_id cannot be restricted by more than one relation if it includes an Equal".

有没有摆脱自动添加该条款的一种方式?我缺少的东西吗?

Is there a way to get rid of the clause added automatically? Am I missing something?

在此先感谢

推荐答案

驾驶员自动确定使用它从群集本身获取元数据表分区键。然后,它使用这个令牌范围追加到CQL,以便它可以从它试图查询特定节点读出的数据组块。换句话说,卡桑德拉认为series_id是你的分区键,而不是meter_id。如果你运行你的表描述的命令,我敢打赌,你会感到惊讶。

The driver automatically determines the partition key using table metadata it fetches from the cluster itself. It then uses this to append the token ranges to your CQL so that it can read a chunk of data from the specific node it's trying to query. In other words, Cassandra thinks series_id is your partition key and not meter_id. If you run a describe command on your table, I bet you'll be surprised.

这篇关于星火卡桑德拉连接器 - where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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