Error parsing query or unsupported statement?

Hi everyone, i’m in the community. I’ve been starting to use scylladb lately and i just noticed that i cant use “brackets” in where clause, at least not to encapsulate blocks, this prevents me from using ‘or’ properly, and yes, im not using allow filtering, anyway, what i noticed is that i cant do this:

select * from users

where (country = ‘BR’ and state = ‘SP’) or (country = ‘BR’ and state = ‘RJ’)

when i try to do this i get an error saying that i’m missing ‘)’

even though i’m not, and weird as it sounds, looking at the docs, it seems to me that i was supposed to be able to do this

Yeap, today this is not actually supported, and the docs can definitely give the opposite impression. Two things:

  1. In Scylla’s parser, WHERE is defined as a sequence of relations joined only by AND, we don’t accept OR.
  2. Parentheses are only allowed around a single relation, so this works: (a = 1) AND (b = 2), but this does not: (a = 1 AND b = 2), and that is why you get the misleading “missing )” error: once the parser sees (, it expects exactly one relation inside, not a nested boolean expression with AND/OR.

Your example is therefore currently unsupported, but you can still try rewriting it. Otherwise: run two separate queries and merge results client-side.

BTW. I’ll fix the docs.

1 Like

(Can’t edit my post any longer, so writing a follow-up comment).

With regards to rewriting the query, for your specific example, you can try factoring out the common part:
SELECT * FROM users
WHERE country = ‘BR’
AND state IN (‘SP’, ‘RJ’);

1 Like

The docs have been fixed here: docs/cql: clarify WHERE clause boolean limitations by ptrsmrn · Pull Request #29100 · scylladb/scylladb · GitHub, and will be officially updated in 2 weeks time with 2026.2 release.