title: How to query a simple epoch-based partition column in Cassandra?
body: <p>I do not know the primary key while querying in Cassandra.<br>
  All I know is the time range for which I want to get the data.<br>
  So I have kept the partition key of my table as the epoch.</p>
  
  <pre><code>CREATE TABLE tmp2 (
      epoch bigint,
      primary key (epoch)
  );
  
  INSERT INTO tmp2 (epoch) values (unixTimestampOf(now()));
  INSERT INTO tmp2 (epoch) values (unixTimestampOf(now()));
  INSERT INTO tmp2 (epoch) values (unixTimestampOf(now()));
  INSERT INTO tmp2 (epoch) values (unixTimestampOf(now()));
  INSERT INTO tmp2 (epoch) values (unixTimestampOf(now()));
  
  
  select * from tmp2;
   epoch
  ---------------
   9410
   8171
   7595
   8746
   6009
  </code></pre>
  
  <p>Note: I have reduced the epochs to more readable numbers here by getting rid of the common prefix 148826477</p>
  
  <p>I try to query this table based on epoch range:</p>
  
  <pre><code>Select * from tmp2 where epoch &gt;= 6009 and epoch &lt;= 7595;
  InvalidRequest: Only EQ and IN relation are supported on the partition key (unless you use the token() function)
  </code></pre>
  
  <p>So I use the token() function and all is good:</p>
  
  <pre><code>Select * from tmp2 where token(epoch) &lt;= token(6009) and token(epoch) &gt;= token(7595);
   epoch
  ---------------
   7595
   8746
   6009
  </code></pre>
  
  <p>However, I am suspicious that using token is not actually giving me querying based on time because token(epoch) and token(epoch+100) might not have same linear relationship as epoch and epoch+100 have.<br>
  Example:</p>
  
  <pre><code>Select * from tmp2 where token(epoch) &lt;= token(7009) and token(epoch) &gt;= token(7595);
  
   epoch
  -------
  (0 rows)
  </code></pre>
  
  <ol>
  <li>Is there a way to query the epoch based partition column in chunks of 1-minute? OR</li>
  <li>Is there a way to get rid of the milliseconds and seconds in the epoch while storing the data, so that the epoch's resolution is only a minute and I can specify the partition easily for minutes?</li>
  </ol>