Questions tagged [cql3]

Cassandra Query Language (CQL) is a SQL (Structured Query Language)-like language for querying Cassandra.

Cassandra Query Language (CQL) is a SQL (Structured Query Language)-like language for querying Cassandra.

Although CQL has many similarities to SQL, there are some fundamental differences.

For example, the CQL adaptation to the Cassandra data model and architecture, doesn't support operations, such as JOINs, which make no sense in a non-relational database.

657 questions
63
votes
3 answers

Cassandra UUID vs TimeUUID benefits and disadvantages

Given that TimeUUID handily allows you to use now() in CQL, are there any reasons you wouldn't just go ahead and always use TimeUUID instead of plain old UUID?
Jay
  • 19,649
  • 38
  • 121
  • 184
54
votes
2 answers

How do secondary indexes work in Cassandra?

Suppose I have a column family: CREATE TABLE update_audit ( scopeid bigint, formid bigint, time timestamp, record_link_id bigint, ipaddress text, user_zuid bigint, value text, PRIMARY KEY ((scopeid, formid), time) ) WITH CLUSTERING…
Aftab
  • 938
  • 1
  • 9
  • 20
53
votes
4 answers

How to auto generate uuid in cassandra CQL 3 command line

Just learning cassandra, is there a way to insert a UUID using CQL, ie create table stuff (uid uuid primary key, name varchar); insert into stuff (name) values('my name'); // fails insert into stuff (uid, name) values(1, 'my name'); // fails Can…
Jay
  • 19,649
  • 38
  • 121
  • 184
50
votes
4 answers

Difference between UPDATE and INSERT in Cassandra?

What is the difference between UPDATE and INSERT when executing CQL against Cassandra? It looks like there used to be no difference, but now the documentation says that INSERT does not support counters while UPDATE does. Is there a "preferred"…
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
43
votes
7 answers

Results pagination in Cassandra (CQL)

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),…
kazy
  • 1,111
  • 2
  • 14
  • 24
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
31
votes
2 answers

alter composite primary key in cassandra CQL 3.0

I'm in a situation where I need to change the the composite primary key as follows: Old Primary Key: (id, source, attribute_name, updated_at); New Primary Key I want: (source, id, attribute_name, updated_at); I issued the following (mysql like)…
aroyc
  • 890
  • 2
  • 13
  • 26
30
votes
1 answer

How to rename table in Cassandra CQL3

I'm trying to rename table created via CQLSH. E.g. rename table "AAA" to "BBB". Can't find any command to do so. Any ideas? Using [cqlsh 3.1.6 | Cassandra 1.2.8 | CQL spec 3.0.0 | Thrift protocol 19.36.0]
Vladimir Kroz
  • 5,237
  • 6
  • 39
  • 50
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
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
24
votes
4 answers

How to list column families in keyspace?

How can I get list of all column families in keyspace in Cassandra using CQL 3?
newbie
  • 24,286
  • 80
  • 201
  • 301
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
20
votes
1 answer

cassandra add column if not exists

I need to insert a new column into an existing column family via a CQL script. I want to do something like: alter COLUMNFAMILY rules ADD rule_template text IF NOT EXISTS; How can I achieve this purely in CQL script?
beterthanlife
  • 1,668
  • 2
  • 18
  • 30
20
votes
3 answers

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

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 '' expecting ')'…
i.petruk
  • 1,276
  • 1
  • 13
  • 18
19
votes
2 answers

Get current date in cassandra cql select

In SQL, I am able to do: select getdate(), getdate() - 7 Which returns the current date as well as current date - 7 days. I want to achieve the same in Cassandra CQL. I tried: select dateof(now()) But that does not work. It works only on insert…
Hitesh
  • 3,449
  • 8
  • 39
  • 57
1
2 3
43 44