In Cassandra CQL, is there a way to query the size of a collection column type?

Viewed 8913

We're looking to be able to do something like..

select * from User where rewards.size > 0

when the schema is

create table user (
    id uuid primary key,
    network_id uuid,
    rewards set<uuid>,
    name text   
);
2 Answers

There is a size() method that does just that.. to give an example of how it is used:

 select order_id,items.item_id,last_modified from person.ecommerce_order   where size(items.item_id)> 1

To explain the query:

items.item_id is a list field .The check is if there are more than one item in the list.

Related