title: Cassandra IN clause on index
body: <p>Assume a simple table with one insert (or without this insert, doesn't really matter).</p>
  
  <pre><code>CREATE TABLE test (
   x int,
   y int,
   z int,
   PRIMARY KEY (x, y, z)
  );
  
  
  create index z_index on test (z);
  
  insert into test(x, y, z) values (1,2,3);
  </code></pre>
  
  <p>I struggle to understand why <strong>I cannot query with an in clause</strong> on the index z:</p>
  
  <blockquote>
    <p>cqlsh:test> select * from test where z in (3);<br>
        Bad Request: PRIMARY KEY part z cannot be restricted (preceding part y is either not                 restricted or by a non-EQ relation)</p>
  </blockquote>
  
  <p>It is possible with a simple equals predicate:</p>
  
  <pre><code>cqlsh:test&gt; select * from test where z = 3;
  
   x | y | z
  ---+---+---
   1 | 2 | 3
  
  (0 rows)
  </code></pre>
  
  <p>I thought having an index on z would keep a mapping from specific values of z to rows but this assumption seems wrong. </p>
  
  <p>Why this doesn't work the way I expected? I guess the index works differently.  </p>
  
  <p>EDIT: I am using [cqlsh 4.1.1 | Cassandra 2.0.6 | CQL spec 3.1.1 | Thrift protocol 19.39.0]</p>