Questions tagged [cql]

CQL (Cassandra Query Language) is used to interact with and query Cassandra tables. Its syntax is similar to SQL, helping to lower the learning curve to working with Cassandra. For the Cypher graph query language, use the cypher tag.

CQL (Cassandra Query Language) is used to interact with and query Cassandra tables. Its syntax is similar to SQL, helping to lower the learning curve to working with Cassandra. Despite their similarities, in many cases CQL behaves very differently from SQL, so it is important to read the documentation before going too far.

Some of the more useful links to documentation on CQL:

2118 questions
34
votes
5 answers

Executing CQL through Shell Script?

I am trying to execute the CQL commands from shell script. I am able to connect to the cqlsh (CQL version i'm using is 1.1.18) but unable to send the queries to cql. Any ideas or suggestion how to proceed on this? Do I need to connect to Cassandra…
Immadisetty
  • 341
  • 1
  • 3
  • 3
34
votes
4 answers

Cassandra: Generate a unique ID?

I'm working on a distributed data base. I'm trying to generate a unique ID that will serve as a column family primary key in cassandra. I read some articles about doing this with Java using UUID but it seems like there is a probability for collision…
user2090879
  • 683
  • 2
  • 10
  • 16
27
votes
2 answers

cassandra primary key column cannot be restricted

I am using Cassandra for the first time in a web app and I got a query problem. Here is my tab : CREATE TABLE vote ( doodle_id uuid, user_id uuid, schedule_id uuid, vote int, PRIMARY KEY ((doodle_id), user_id,…
Orodan
  • 1,047
  • 2
  • 13
  • 24
25
votes
1 answer

Check a rows TTL in cassandra?

I have a table/column family which I am inserting rows that expire after a certain amount of time. Is it possible to then query the table to check which rows are going to expire soon (for diagnostic purposes, ie something like this: select subject,…
Jay
  • 19,649
  • 38
  • 121
  • 184
24
votes
2 answers

Cassandra: Unable to coerce '2016-04-06 13:06:11.534000' to a formatted date (long)

I am trying to UPDATE an existing item in my cassandra DB using cqlsh: $ > UPDATE allEvents SET "isLastEvent" = True WHERE "websiteId" = 'sd-8231' AND "purchaser" = False AND "currentTime" = '2016-04-06 13:06:11.534000'; And I got…
farhawa
  • 10,120
  • 16
  • 49
  • 91
24
votes
3 answers

Cassandra Error - Clustering column cannot be restricted (preceding column is restricted by a non-EQ relation)

We are using Cassandra as the data historian for our fleet management solution. We have a table in Cassandra , which stores the details of journey made by the vehicle. The table structure is as given below CREATE TABLE journeydetails( bucketid…
Sabarish Sathasivan
  • 1,196
  • 2
  • 19
  • 42
23
votes
4 answers

How do you create the first user in Cassandra DB

How does one create the first user in a cassandra database? I tried: CREATE USER username WITH PASSWORD ""; and its says: Bad Request: Only superusers are allowed to perform CREATE USER queries But I have never created a user before this attempt,…
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
23
votes
4 answers

How to check if a Cassandra table exists

Is there an easy way to check if table (column family) is defined in Cassandra using CQL (or API perhaps, using com.datastax.driver)? Right now I am leaning towards executing SELECT 1 FROM table and checking for exception but maybe there is a better…
Datageek
  • 25,977
  • 6
  • 66
  • 70
22
votes
3 answers

How to copy data from a Cassandra table to another structure for better performance

In several places it's advised to design our Cassandra tables according to the queries we are going to perform on them. In this article by DataScale they state this: The truth is that having many similar tables with similar data is a good thing in…
astrojuanlu
  • 6,744
  • 8
  • 45
  • 105
22
votes
7 answers

select count(*) runs into timeout issues in Cassandra

Maybe it is a stupid question, but I'm not able to determine the size of a table in Cassandra. This is what I tried: select count(*) from articles; It works fine if the table is small but once it fills up, I always run into timeout…
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239
22
votes
5 answers

Cassandra cqlsh - how to show microseconds/milliseconds for timestamp columns?

I'm inserting into a Cassandra table with timestamp columns. The data I have comes with microsecond precision, so the time data string looks like this: 2015-02-16T18:00:03.234+00:00 However, in cqlsh when I run a select query the microsecond data is…
WillZ
  • 3,775
  • 5
  • 30
  • 38
21
votes
1 answer

Select first N rows of Cassandra table

As stated in this doc to select a range of rows i have to write this: select first 100 col1..colN from table; but when I launch this on cql shell I get this error:
OiRc
  • 1,602
  • 4
  • 21
  • 60
21
votes
5 answers

How Can I Search for Records That Have A Null/Empty Field Using CQL?

How can I write a query to find all records in a table that have a null/empty field? I tried tried the query below, but it doesn't return anything. SELECT * FROM book WHERE author = 'null';
HappyCoder86
  • 2,267
  • 3
  • 25
  • 40
20
votes
1 answer

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

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…
karthi
  • 243
  • 1
  • 2
  • 8
20
votes
1 answer

Cassandra - querying on clustering keys

I am just getting start on Cassandra and I was trying to create tables with different partition and clustering keys to see how they can be queried differently. I created a table with primary key of the form - (a),b,c where a is the partition key and…
user3376961
  • 867
  • 2
  • 12
  • 17