title: Using IN operator in CQL on partition key and (clustering key or indexed column)
body: <p>I have an alerts table. I want to query on it using the IN operator on 2 columns and using the greater than operator on one column. I have tried the below things with no luck. Can someone please tell me the DB design to make the query work?
  My environment details: [cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 | Native protocol v3]</p>
  
  <p>With 'type' in partition key:</p>
  
  <pre><code>CREATE TABLE alerts (
      serialNumber text,
      time bigint,
      type text,
      time2 int,
      status text,
      parentId int,
      PRIMARY KEY ((serialNumber,type), time)
   ) WITH CLUSTERING ORDER BY (time DESC);
  
  cqlsh:testdb&gt; select * from alerts WHERE serialNumber IN ( '1','2') AND type IN ( '1','2','3' ) AND time &gt; 1;
  code=2200 [Invalid query] message="Partition KEY part serialNumber cannot be restricted by IN relation (only the last part of the partition key can)"
  </code></pre>
  
  <p>With 'type' in clustering key:</p>
  
  <pre><code>CREATE TABLE alerts (
      serialNumber text,
      time bigint,
      type text,
      time2 int,
      status text,
      parentId int,
      PRIMARY KEY (serialNumber, type, time)
  ) WITH CLUSTERING ORDER BY (type ASC,time DESC);
  
  cqlsh:testdb&gt; select * from alerts WHERE serialnumber IN ( '1','2') AND type IN ( 'a','b') and time &gt; 1;
  code=2200 [Invalid query] message="Clustering column "type" cannot be restricted by an IN relation"
  </code></pre>
  
  <p>With index on type:</p>
  
  <pre><code>CREATE TABLE alerts (
      serialNumber text,
      time bigint,
      type text,
      time2 int,
      status text,
      parentId int,
      PRIMARY KEY (serialNumber, time)
  ) WITH CLUSTERING ORDER BY (time DESC);
  CREATE INDEX alertsTypeIndex ON alerts(type);
  
  select * from alerts WHERE serialnumber IN ( '1','2') and time &gt; 1 AND type IN ( 'a','b');
  code=2200 [Invalid query] message="IN predicates on non-primary-key columns (type) is not yet supported"
  
  select * from alerts WHERE serialnumber IN ( '1','2') and time &gt; 1 AND type = 'a';
  code=2200 [Invalid query] message="Select on indexed columns and with IN clause for the PRIMARY KEY are not supported"
  </code></pre>