How can I run the CQL query "(col1, col2) IN ((1,2), (3,4))" with GoCQLX?

149 Views Asked by At

Well, the title may be not quite informative, sorry.

If I use

qb.Select(...)
  .Where(
    qb.Eq("part_key_col1"),
    qb.Eq("part_key_col1"), 
    qb.In("clust_key_col1"),
    qb.In("clust_key_col2")
  )

, query builder constructs:

SELECT ...
  WHERE part_key_col1 = ?
  AND part_key_col1 = ?
  AND clust_key_col1 IN ?
  AND clust_key_col2 in ?

Now if I pass, say, 2 clust_key_col1 (e.g. "hello" and "world") and 2 clust_key_col2 values ("foo" and "bar"), it builds:

SELECT ...
  WHERE part_key_col1 = ?
  AND part_key_col1 = ?
  AND clust_key_col1 IN ("hello", "world")
  AND clust_key_col2 in ("foo", "bar")

This leads to 4 possible matches:

hello foo
hello bar
world foo
world bar

How should I use gocqlx qb to construct this query: WHERE (part_key_col1, part_key_col2) IN (("hello", "foo"), ("world", "bar")) ? I want to pass arbitrary number of elements.

1

There are 1 best solutions below

0
Erick Ramirez On

On a quick research, it doesn't appear as though the GoCQLX query builder supports complex nesting when using the IN() operator.

You have better luck logging a ticket with the team at Scylla. I've tagged your question so hopefully someone will see it. You can also create an issue against the GoCQLX repository. Cheers!