title: Iterating through Cassandra wide row with CQL3
body: <p>How can I pull in a range of Composite columns with CQL3?</p>
  
  <p>Consider the following:</p>
  
  <pre><code>CREATE TABLE Stuff (
      a int,
      b text,
      c text,
      d text,
      PRIMARY KEY (a,b,c)
  );
  </code></pre>
  
  <p>In Cassandra what this effectively does is creates a ColumnFamily with integer rows (values of a) and with CompositeColumns composed of the values of b and c and the literal string 'd'. Of course this is all covered up by CQL3 so that we will <em>think</em> that we're inserting into individual database rows... but I digress.</p>
  
  <p>And consider the following set of inputs:</p>
  
  <pre><code>INSERT INTO Stuff (a,b,c,d) VALUES (1,'A','P','whatever0');
  INSERT INTO Stuff (a,b,c,d) VALUES (1,'A','Q','whatever1');
  INSERT INTO Stuff (a,b,c,d) VALUES (1,'A','R','whatever2');
  INSERT INTO Stuff (a,b,c,d) VALUES (1,'A','S','whatever3');
  INSERT INTO Stuff (a,b,c,d) VALUES (1,'A','T','whatever4');
  INSERT INTO Stuff (a,b,c,d) VALUES (1,'B','P','whatever5');
  INSERT INTO Stuff (a,b,c,d) VALUES (1,'B','Q','whatever6');
  INSERT INTO Stuff (a,b,c,d) VALUES (1,'B','R','whatever7');
  INSERT INTO Stuff (a,b,c,d) VALUES (1,'B','S','whatever8');
  INSERT INTO Stuff (a,b,c,d) VALUES (1,'B','T','whatever9');
  </code></pre>
  
  <p>In my current use case, I want to read all of the values of Stuff, <code>n</code> values at a time. How do I do this? Here's my current take using <code>n=4</code>:</p>
  
  <pre><code>SELECT * FROM Stuff WHERE a=1 LIMIT 4;
  </code></pre>
  
  <p>And as expected I get:</p>
  
  <pre><code> a | b | c | d
  ---+---+---+-----------
   1 | A | P | whatever0
   1 | A | Q | whatever1
   1 | A | R | whatever2
   1 | A | S | whatever3
  </code></pre>
  
  <p>The trouble that I run into is how do I get the next 4? Here is my attempt:</p>
  
  <pre><code>SELECT * FROM Stuff WHERE a=1 AND b='A' AND c&gt;'S' LIMIT 4;
  </code></pre>
  
  <p>This doesn't work because we've constrained b to equal 'A' - which is a reasonable thing to do! But I've found nothing in the CQL3 syntax that allows me to keep iterating anyway. I wish I could do something like:</p>
  
  <pre><code>SELECT * FROM Stuff WHERE a=1 AND {b,c} &gt; {'A','S'} LIMIT 4;
  </code></pre>
  
  <p>How do I achieve my desired result. Namely, how do I make CQL3 return:</p>
  
  <pre><code> a | b | c | d
  ---+---+---+-----------
   1 | A | T | whatever0
   1 | B | P | whatever1
   1 | B | Q | whatever2
   1 | B | R | whatever3
  </code></pre>