卡桑德拉行在火花中的写入时间 [英] writetime of cassandra row in spark

查看:71
本文介绍了卡桑德拉行在火花中的写入时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在cassandra中使用spark,我想从cassandra表中选择行的writeTime。这是我的要求:

i'm using spark with cassandra, and i want to select from my cassandra table the writeTime of my row. This is my request :

   val lines = sc.cassandraTable[(String, String, String, Long)](CASSANDRA_SCHEMA, table).select("a", "b", "c", "writeTime(d)").count()

,但显示此错误:

java.io.IOException: Column channal not found in table test.mytable

我也尝试过此请求

   val lines = sc.cassandraTable[(String, String, String, Long)](CASSANDRA_SCHEMA, table).select("a", "b", "c", WRITETIME("d")").count()

但它显示此错误:

<console>:25: error: not found: value WRITETIME

请问我如何获取行的writeTime。
谢谢。

Please how can i get the writeTime of my row. Thanks.

推荐答案

编辑:此问题已在连接器的1.2版本中修复


当前,连接器不支持通过CQL函数传递zh-cn从Cassandra阅读。我已经注意到了这一点,并将为实现此功能开张票。

This has been fixed in the 1.2 release of the connector

Currently the Connector doesn't support passing through CQL functions when reading from Cassandra. I've taken note of this and will start up a ticket for implementing this functionality.

https://datastax-oss.atlassian.net/browse/SPARKC-55

要解决此问题,您始终可以使用直接操作中的连接器,例如in

For a workaround you can always use the direct connector within your operations like in

import com.datastax.spark.connector.cql.CassandraConnector

val cc = CassandraConnector(sc.getConf)
val select = s"SELECT WRITETIME(userId) FROM cctest.users where userid=?"
val ids = sc.parallelize(1 to 10)
ids.flatMap(id =>
      cc.withSessionDo(session =>
        session.execute(select, id.toInt: java.lang.Integer)


修改的代码通过RDD值从Cassandra表中过滤

这篇关于卡桑德拉行在火花中的写入时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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