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
13
votes
3 answers

CQL: how to check if keyspace exists?

I need to check if certain keyspace exists in Cassandra database. I need to write smth like this: if (keyspace KEYSPACE_NAME not exists) create keyspace KEYSPACE_NAME; There's a command describe keyspace, but can I somehow retrieve information from…
Yury Pogrebnyak
  • 4,093
  • 9
  • 45
  • 78
13
votes
2 answers

Cassandra Allow filtering

I have a table as below CREATE TABLE test ( day int, id varchar, start int, action varchar, PRIMARY KEY((day),start,id) ); I want to run this query Select * from test where day=1 and start > 1475485412 and start < 1485785654 and…
Bharathi
  • 451
  • 1
  • 6
  • 17
13
votes
2 answers

How can i describe table in cassandra database?

$describe = new Cassandra\SimpleStatement(<<execute($describe); i used above code but it is not working. how can i fetch field name and it's data type from Cassandra table ?
Nirali Kavar
  • 956
  • 2
  • 8
  • 17
13
votes
3 answers

Cassandra: List 10 most recently modified records

I'm having trouble trying to model my data such that I can efficiently query Cassandra for the last 10 (any number actually) records that were most recently modified. Each record has a last_modified_date column that is set by the application when…
Shaun
  • 159
  • 1
  • 8
13
votes
1 answer

How does the Leveled Compaction Strategy ensure 90% of reads are from one sstable

I am trying to understand how the Leveled Compaction Strategy in Cassandra works that guarantees 90% of all reads will be satisfied from a single sstable. From DataStax Doc: new sstables are added to the first level, L0, and immediately compacted…
Chaity
  • 1,348
  • 13
  • 20
13
votes
2 answers

Error creating table in cassandra - Bad Request: Only clustering key columns can be defined in CLUSTERING ORDER directiv

I get the above error when I try to use following cql statement, not sure whats wrong with it. CREATE TABLE Stocks( id uuid,   market text,   symbol text, value text, time timestamp,   PRIMARY KEY(id) ) WITH CLUSTERING ORDER BY (time…
Lahiru
  • 679
  • 1
  • 6
  • 19
13
votes
4 answers

Cassandra 2 - list existing indexes with CQL 3

Is there a CQL query to list all existing indexes for particular key space, or column family?
Maciej Miklas
  • 3,305
  • 4
  • 27
  • 52
13
votes
4 answers

Cassandra selective copy

I want to copy selected rows from a columnfamily to a .csv file. The copy command is available just to dump a column or entire table to a file without where clause. Is there a way to use where clause in copy command? Another way I thought of was, Do…
Dhamodaran
  • 313
  • 1
  • 3
  • 7
13
votes
2 answers

Cassandra-CQl : Change Clustering order for Created Column Family

I know that I can define clustering order when I create a table by cql as code below: create table test( id int, time timestamp, value text, primary key(id,time)) with clustering order by (time desc) but I want change the clustering for table test…
12
votes
3 answers

How to view all tables in CQL and CQLSH?

I'm trying to explore the database and want to see all tables that exist there. What's the command that's equivalent to SHOW TABLES; in SQL?
Ahmad Farid
  • 14,398
  • 45
  • 96
  • 136
12
votes
1 answer

How to change CQL version?

When i try to connect to cqlsh I get this error: Connection error: ('Unable to connect to any servers', {'127.0.0.1': ProtocolError("cql_version '3.3.1' is not supported by remote (w/ native protocol). Supported versions: [u'3.4.4']",)}) If I add…
Most31
  • 400
  • 4
  • 18
12
votes
2 answers

Inserting null values into cassandra

I have some fields that I am storing into Cassandra, but some of them could be null at any given point. As there are quite a lot of them, it makes the code much more readable if I don’t check each one for null before adding it to the INSERT. Is…
ArchitGarg
  • 121
  • 1
  • 1
  • 4
12
votes
2 answers

What is the byte size of common Cassandra data types - To be used when calculating partition disk usage?

I am trying to calculate the the partition size for each row in a table with arbitrary amount of columns and types using a formula from the Datastax Academy Data Modeling Course. In order to do that I need to know the "size in bytes" for some common…
nicgul
  • 237
  • 1
  • 2
  • 10
12
votes
1 answer

How to add multiple columns in cassandra table?

I need to add some new columns to my existing column_family/table in cassandra. I can add single column like this : ALTER TABLE keyspace_name.table_name ADD column_name cql_type; Can I add all new columns using a single query? If yes, how to do it…
Pankaj Goyal
  • 1,448
  • 3
  • 15
  • 25
12
votes
2 answers

Error: unable to connect to cassandra server. Unconfigured table

I am trying to connect to cassandra, which is running on local desktop, via cassandra-driver for python using this simple code. from cassandra.cluster import Cluster cluster = Cluster() session = cluster.connect() and getting this error:…
Olzhabay
  • 165
  • 1
  • 1
  • 7