title: Table Partitioned by Timestamp Field
body: <p>In order to generate some summary figures we are importing data periodically to Hive. We are currently using a CSV file format and its layout is as follows:</p>
  
  <pre><code>operation,item,timestamp,user,marketingkey
  </code></pre>
  
  <p>Currently we have a few queries that are performing grouping over date (yyyy-mm-dd) of timestamp field.</p>
  
  <p>The files that are being imported are holding sometimes more days and I would like to store it in a partitioned way. Is there a way to do it with Hive, I have build the table based on the following DDL:</p>
  
  <pre><code>CREATE TABLE 
     partitionedTable (name string) 
  PARTITIONED BY (time bigint) 
  ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
  </code></pre>
  
  <p>The data loading was done like:</p>
  
  <pre><code>LOAD DATA LOCAL INPATH 
     '/home/spaeth/tmp/hadoop-billing-data/extracted/testData.csv' 
  INTO TABLE partitionedTable PARTITION(time='2013-05-01');
  </code></pre>
  
  <p>But I would like that hive applies the partitioning in an automatic way based on a field that comes within the file that is being imported. For example:</p>
  
  <pre><code>login,1,1370793184,user1,none --&gt; stored to partition 2013-06-09
  login,2,1360793184,user1,none --&gt; stored to partition 2013-02-13
  login,1,1360571184,user2,none --&gt; stored to partition 2013-02-11
  buy,2,1360501184,user2,key1   --&gt; stored to partition 2013-02-10
  </code></pre>