Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot restrict clustering columns by in relations when a collection is selected by the query

Tags:

cassandra

I am reading this article which shows how to write queries with IN clause in cassandra

https://www.datastax.com/dev/blog/a-deep-look-to-the-cql-where-clause

I created the following table

create table foo2(id bigint, bid bigint, data set<bigint>, primary key (id, bid));

insert into foo2 (id, bid, data) values (1, 1, {1, 2});
insert into foo2 (id, bid, data) values (1, 2, {3, 4});
insert into foo2 (id, bid, data) values (1, 3, {5, 6});

Now I write the query

select * from foo2 where id = 1 and bid IN (1, 2, 3);

Cannot restrict clustering columns by in relations when a collection is selected by the query.

I googled on this error and found this

https://issues.apache.org/jira/browse/CASSANDRA-12654

and it says that the issue is resolved in Cassandra 4.0 but I a using

[cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4]

Is there a workaround for this (apart from the mother of all answers for any Cassandra question change your schema)

Some people are pointing here : Cassandra IN query not working if table has SET type column

But this does not question does not have a clearly marked answer.

like image 781
Knows Not Much Avatar asked Apr 24 '17 05:04

Knows Not Much


1 Answers

You may not like this answer but you will have to change the schema a bit to work around this issue. By using frozen the issue will disappear. Note that this issue is also affecting UDT's and that for them it also get's fixed by using frozen.

like image 52
Thim Anneessens Avatar answered Oct 06 '22 20:10

Thim Anneessens