Ying LEE
Ying LEE

Reputation: 93

How to select the 1st or last Element of a LIST column in Cassandra CQL?

I have a Cassandra table of files, similar to the following (fake) structure:

CREATE TABLE files{
filename: text;
versions:LIST<{timestamp, filesize}>
}

I carefully always insert the latest version at the beginning of the LIST. And I tried to run

select filename, versions[0] from files; 

I met the following error:

SyntaxException:

I couldn't find a solution on StackOverflow and Internet. Just wonder whether this is possible in Cassandra CQL? Of course, if there is no such a solution, I will process data at client side.

Thank you in advance,

Ying

Upvotes: 3

Views: 1868

Answers (1)

undefined_variable
undefined_variable

Reputation: 6218

The functionality is not yet available CASSANDRA-7396.

As of now you will have to fetch the complete list and filter it at application level.

Upvotes: 2

Related Questions