cql

How will i know that record was duplicate or it was inserted successfully?

…衆ロ難τιáo~ 提交于 2019-12-05 06:38:40
Here is my CQL table: CREATE TABLE user_login ( userName varchar PRIMARY KEY, userId uuid, fullName varchar, password text, blocked boolean ); I have this datastax java driver code PreparedStatement prepareStmt= instances.getCqlSession().prepare("INSERT INTO "+ AppConstants.KEYSPACE+".user_info(userId, userName, fullName, bizzCateg, userType, blocked) VALUES(?, ?, ?, ?, ?, ?);"); batch.add(prepareStmt.bind(userId, userData.getEmail(), userData.getName(), userData.getBizzCategory(), userData.getUserType(), false)); PreparedStatement pstmtUserLogin = instances.getCqlSession().prepare("INSERT

Finding distinct values of non Primary Key column in CQL Cassandra

寵の児 提交于 2019-12-05 05:39:04
I use the following code for creating table: CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; USE mykeyspace; CREATE TABLE users ( user_id int PRIMARY KEY, fname text, lname text ); INSERT INTO users (user_id, fname, lname) VALUES (1745, 'john', 'smith'); INSERT INTO users (user_id, fname, lname) VALUES (1744, 'john', 'doe'); INSERT INTO users (user_id, fname, lname) VALUES (1746, 'john', 'smith'); I would like to find the distinct value of lname column (that is not a PRIMARY KEY). I would like to get the following result: lname -------

how to construct range query in cassandra?

不打扰是莪最后的温柔 提交于 2019-12-05 05:34:09
CREATE TABLE users ( userID uuid, firstname text, lastname text, state text, zip int, age int, PRIMARY KEY (userID) ); I want to construct the following queries: select * from users where age between 30 and 40 select * from users where state in "AZ" AND "WA" I know I need two more tables to do this query but I dont know how the should be? EDIT From Carlo's comments, I see this is the only possibility CREATE TABLE users ( userID uuid, firstname text, lastname text, state text, zip int, age int, PRIMARY KEY (age,zip,userID) ); Now to select Users with age between 15 and 30. this is the only

What should be the connection string while using CQL jdbc driver

一个人想着一个人 提交于 2019-12-05 03:29:26
What should be the connection string while using CQL jdbc driver? Will I be able to find a proper/complete example for CQL using CQL JDBC driver in Java online? You'll need the cql jar from the apache site. Here's the basic test I used after entering data via CLI (using sample from wiki): public class CqlJdbcTestBasic { public static void main(String[] args) { Connection con = null; try { Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver"); con = DriverManager.getConnection("jdbc:cassandra:root/root@localhost:9160/MyKeyspace"); String query = "SELECT KEY, 'first', last FROM User

Cassandra hangs on arbitrary commands

折月煮酒 提交于 2019-12-05 02:40:09
问题 We're hosting Cassandra 2.0.2 cluster on AWS. We've recently started upgrading from normal to SSD drives, by bootstrapping new and decommissioning old nodes. It went fairly well, aside from two nodes hanging forever on decommission. Now, after the new 6 nodes are operational, we noticed that some of our old tools, using phpcassa stopped working. Nothing has changed with security groups, all ports TCP/UDP are open, telnet can connect via 9160, cqlsh can 'use' a cluster, select data, however,

“Bad Request: PRIMARY KEY part to_id cannot be restricted” when trying to select using where condition

妖精的绣舞 提交于 2019-12-05 02:05:35
问题 Here is my cassandra table for chat kind of application: CREATE TABLE tax_keyspace_dev.chat_messages ( message text, when timestamp, from_id text, to_id text, read boolean, participants text, PRIMARY KEY(participants, when, to_id) ); This query work: select * from tax_keyspace_dev.chat_messages where participants='caone@one.com_shashank_shrivastava@acme.com' order by when; but following queries don't work: select * from tax_keyspace_dev.chat_messages where to_id='caone@one.com' order by when;

Cassandra Non-Counter Family

馋奶兔 提交于 2019-12-05 01:21:58
I'm attempted to execute the following CQL 3 statement CREATE TABLE summary ( id uuid, "client" bigint, "campaign" text, "unit" bigint, "view" counter, PRIMARY KEY ("client", "campaign", "unit")); The error I'm getting is that I cannot create a counter column on a non-counter column family. Any ideas? The solution to this issue is that any non-counter column must be part of the primary key. The column id uuid was the one causing the issue, removing it allowed the table to be created. Tables that contain counters can only contain counters. Andremoniy That's a limitation of the current counter

Non frozen collections and user defined types on Cassandra 2.1.8

℡╲_俬逩灬. 提交于 2019-12-04 23:19:31
I'm trying to run the following example from here CREATE TYPE address ( street text, city text, zip int ); CREATE TABLE user_profiles ( login text PRIMARY KEY, first_name text, last_name text, email text, addresses map<text, address> ); However, when I try to create the user_profiles table, I get the following error: InvalidRequest: code=2200 [Invalid query] message="Non-frozen collections are not allowed inside collections: map<text, address> Any thoughts on why this could be happening? I am running 2.1.8 and I get the same error message. To fix this, you need the frozen keyword: CREATE TABLE

High number of tombstones with TTL columns in Cassandra

一曲冷凌霜 提交于 2019-12-04 20:15:23
I have a cassandra Column Family, or CQL table with the following schema: CREATE TABLE user_actions ( company_id varchar, employee_id varchar, inserted_at timeuuid, action_type varchar, PRIMARY KEY ((company_id, employee_id), inserted_at) ) WITH CLUSTERING ORDER BY (inserted_at DESC); Basically a composite partition key that is made up of a company ID and an employee ID, and a clustering column, representing the insertion time, that is used to order the columns in reverse chronological order (newest actions are at the beginning of the row). Here's what an insert looks like: INSERT INTO user

When are rows overwritten in cassandra

左心房为你撑大大i 提交于 2019-12-04 19:14:03
问题 My understanding that rows are overwritten when another row with identical primary keys is inserted. For example: I have columns (user_id int, item_id int, site_id int) , and my PRIMARY KEY(user_id, item_id) If I had the following table: user_id, item_id, site_id 2 3 4 and I insert user_id : 2, item_id : 3, site_id : 10 , my new table would be: user_id, item_id, site_id 2 3 10 not user_id, item_id, site_id 2 3 4 2 3 10 Is this simple case hold in all cases? Are any subtleties that I likely