Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select first N rows of Cassandra table

Tags:

cassandra

cql

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:

<ErrorMessage code=2000 [Syntax error in CQL query] message="line 1:13 no viable alternative at input '100' (select [first] 100...)">

What's wrong?

like image 829
OiRc Avatar asked Jun 16 '15 07:06

OiRc


People also ask

How do I limit rows in Cassandra?

To allow Cassandra to select a contiguous set of rows, the WHERE clause must apply an equality condition to the king component of the primary key. The ALLOW FILTERING clause is also required. ALLOW FILTERING provides the capability to query the clustering columns using any condition.

How do I find the number of rows in a Cassandra table?

A SELECT expression using COUNT(*) returns the number of rows that matched the query. Alternatively, you can use COUNT(1) to get the same result.

How do I get unique values in Cassandra?

How to use Distinct in Cassandra Query Language. In cassandra you can only select the distinct records from Partition Key column or columns. If Partition key consists of multiple columns, you have to provide all of the columns otherwise you will get an error.


1 Answers

According to the Docs, key word first is to limit the number of Columnns, not rows

to limit the number of rows , you must just keyword limit.

select col1..colN from table  limit 100;

the default limit is 10000

like image 70
Thorarins Avatar answered Sep 18 '22 19:09

Thorarins