Apache Cassandra "no viable alternative at input 'OR' "

Viewed 403

My table looks like :

CREATE TABLE prod_cust (
    pid bigint,
    cid bigint,
    effective_date date,
    expiry_date date,
    PRIMARY KEY ((pid, cid))
);

My below query is giving no viable alternative at input 'OR' error

SELECT * FROM prod_cust 
where 
pid=101 and cid=201 
OR 
pid=102 and cid=202;

Does Cassandra not support OR operator if not, Is there any alternate way to achieve my result.

1 Answers

CQL does not support the OR operator. Sometimes you can get around that by using IN. But even IN won't let you do what you're attempting.

I see two options:

  • Submit each side of your OR as individual queries.
  • Restructure the table to better-suit what you're trying to do. Doing a "port-over" from a RDBMS to Cassandra almost never works as intended.
Related