datastax-enterprise

How do I set the consistency level of an individual CQL query in CQL3?

こ雲淡風輕ζ 提交于 2019-11-29 07:19:19
问题 In the earlier beta releases of CQL, there was a command I could use to set the read / write consistency of an individual CQL operation. It looked like this: SELECT * FROM users WHERE state='TX' USING CONSISTENCY QUORUM; I use CQL3 regularly and have a use-case where I need to be able to perform a read with a higher consistency level than the rest of our application. I looked through the CQL3 reference and didn't find any mention of any CQL syntax that allows me to change the consistency

Spark JoinWithCassandraTable on TimeStamp partition key STUCK

给你一囗甜甜゛ 提交于 2019-11-29 04:34:16
I'm trying to filter on a small part of a huge C* table by using: val snapshotsFiltered = sc.parallelize(startDate to endDate).map(TableKey(_)).joinWithCassandraTable("listener","snapshots_tspark") println("Done Join") //******* //get only the snapshots and create rdd temp table val jsons = snapshotsFiltered.map(_._2.getString("snapshot")) val jsonSchemaRDD = sqlContext.jsonRDD(jsons) jsonSchemaRDD.registerTempTable("snapshots_json") With: case class TableKey(created: Long) //(created, imei, when)--> created = partititon key | imei, when = clustering key And the cassandra table schema is:

Prepared Statement with collection in IN clause in Datastax Cassandra CQL driver

落爺英雄遲暮 提交于 2019-11-29 01:39:32
I am trying to run the following query SELECT edge_id, b_id FROM booking_by_edge WHERE edge_id IN ? I bind Java list of Long's as a parameter and I get an exception SyntaxError: line 0:-1 mismatched input '<EOF>' expecting ')' (ResultSetFuture.java:242) If I try to use (?) it expects single Long item to be bound, but I need a collection Is there an error in my syntax? Tested in Cassandra 2.1.3, the following code snippet works: PreparedStatement prepared = session.prepare("SELECT edge_id, b_id FROM booking_by_edge WHERE edge_id IN ?;"); List<Long> edgeIds = Arrays.asList(1L, 2L, 3L); session

Results pagination in Cassandra (CQL)

耗尽温柔 提交于 2019-11-28 05:18:59
I am wondering how can I achieve pagination using Cassandra. Let us say that I have a blog. The blog lists max 10 posts per page. To access next posts a user must click on pagination menu to access page 2 (posts 11-20), page 3 (posts 21-30), etc. Using SQL under MySQL, I could do the following: SELECT * FROM posts LIMIT 20,10; The first parameter of LIMIT is offset from the beginning of result set and second argument is amount of rows to fetch. The example above returns 10 rows starting from row 20. How can I achieve the same effect in CQL? I have found some solutions on Google, but all of

How to load Spark Cassandra Connector in the shell?

若如初见. 提交于 2019-11-28 03:41:38
I am trying to use Spark Cassandra Connector in Spark 1.1.0. I have successfully built the jar file from the master branch on GitHub and have gotten the included demos to work. However, when I try to load the jar files into the spark-shell I can't import any of the classes from the com.datastax.spark.connector package. I have tried using the --jars option on spark-shell and adding the directory with the jar file to Java's CLASSPATH. Neither of these options work. In fact, when I use the --jars option, the logging output shows that the Datastax jar is getting loaded, but I still cannot import

Spark JoinWithCassandraTable on TimeStamp partition key STUCK

萝らか妹 提交于 2019-11-27 18:34:47
问题 I'm trying to filter on a small part of a huge C* table by using: val snapshotsFiltered = sc.parallelize(startDate to endDate).map(TableKey(_)).joinWithCassandraTable("listener","snapshots_tspark") println("Done Join") //******* //get only the snapshots and create rdd temp table val jsons = snapshotsFiltered.map(_._2.getString("snapshot")) val jsonSchemaRDD = sqlContext.jsonRDD(jsons) jsonSchemaRDD.registerTempTable("snapshots_json") With: case class TableKey(created: Long) //(created, imei,

Prepared Statement with collection in IN clause in Datastax Cassandra CQL driver

我的未来我决定 提交于 2019-11-27 16:03:47
问题 I am trying to run the following query SELECT edge_id, b_id FROM booking_by_edge WHERE edge_id IN ? I bind Java list of Long's as a parameter and I get an exception SyntaxError: line 0:-1 mismatched input '<EOF>' expecting ')' (ResultSetFuture.java:242) If I try to use (?) it expects single Long item to be bound, but I need a collection Is there an error in my syntax? 回答1: Tested in Cassandra 2.1.3, the following code snippet works: PreparedStatement prepared = session.prepare("SELECT edge_id

Coordinator node timed out waiting for replica nodes in Cassandra Datastax while insert data

风格不统一 提交于 2019-11-27 15:59:12
问题 When I try to Insert data in Cassandra using the below query I am getting the below mentioned error cqlsh:assign> insert into tblFiles1(rec_no,clientid,contenttype,datafiles,filename) values(1,2,'gd','dgfsdg','aww'); WriteTimeout: code=1100 [Coordinator node timed out waiting for replica nodes' responses] message="Operation timed out - received only 0 responses." info={'received_responses': 0, 'required_responses': 1, 'consistency': 'ONE'} My Version of Cassandra and DSE : [cqlsh 5.0.1 |

Results pagination in Cassandra (CQL)

依然范特西╮ 提交于 2019-11-27 00:42:55
问题 I am wondering how can I achieve pagination using Cassandra. Let us say that I have a blog. The blog lists max 10 posts per page. To access next posts a user must click on pagination menu to access page 2 (posts 11-20), page 3 (posts 21-30), etc. Using SQL under MySQL, I could do the following: SELECT * FROM posts LIMIT 20,10; The first parameter of LIMIT is offset from the beginning of result set and second argument is amount of rows to fetch. The example above returns 10 rows starting from