I have the following table:
CREATE TABLE tab1 (id int PRIMARY KEY, price int, name text);
The following queries return errors:
SELECT name FROM tab1 WHERE id > 5;
SELECT name FROM tab1 WHERE id > 5 ALLOW FILTERING;
How can I fix it?
I have the following table:
CREATE TABLE tab1 (id int PRIMARY KEY, price int, name text);
The following queries return errors:
SELECT name FROM tab1 WHERE id > 5;
SELECT name FROM tab1 WHERE id > 5 ALLOW FILTERING;
How can I fix it?
Copyright © 2021 Jogjafile Inc.
SELECT name FROM tab1 WHERE id > 5 ALLOW FILTERING;will not give an error since you are usingallow filtering. If your queries require to useallow filtering, then you need to redesign your tables according to the queries. Allow filtering is not efficient way of querying your tables, especially in production. please check hereSELECT name FROM tab1 WHERE id > 5;will give you an errorThe reason is; Cassandra doesn't work as how relational database works. The table structure doesn't allow you to run any query you want to, so you model your tables according to queries.
Please check here for where clause details. As it is stated in the documentation
The partition key columns support only two operators: = and IN, in your case you are usinggreater, which causes you to get an error.