title: How can I partition a table with HIVE?
body: <p>I've been playing with Hive for few days now but I still have a hard time with partition.</p>
  
  <p>I've been recording Apache logs (Combine format) in Hadoop for few months. They are stored in row text format, partitioned by date (via flume):
  /logs/yyyy/mm/dd/hh/*</p>
  
  <p>Example:</p>
  
  <pre><code>/logs/2012/02/10/00/Part01xx (02/10/2012 12:00 am)
  /logs/2012/02/10/00/Part02xx
  /logs/2012/02/10/13/Part0xxx (02/10/2012 01:00 pm)
  </code></pre>
  
  <p>The date in the <a href="http://httpd.apache.org/docs/1.3/logs.html#combined" rel="nofollow noreferrer">combined log</a> file is following this format [10/Feb/2012:00:00:00 -0800] </p>
  
  <p>How can I create a external table with partition in Hive that use my physical partition. I can't find any good documentation on Hive partition. I found related Question such as:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/5760960/importing-data-from-hdfs-to-hive-table">Importing data from HDFS to Hive table</a> </li>
  <li><a href="https://stackoverflow.com/questions/5316960/partition-column-in-hive">partition column in hive</a></li>
  </ul>
  
  <p>If I load my logs in an external table with Hive, I cannot partition with the time, since it's not the good format (Feb &lt;=> 02). Even if if it was in a good format how do i transform a string "10/02/2012:00:00:00 -0800" into multiple directory "/2012/02/10/00"?</p>
  
  <p>I could eventually use pig script to convert my raw logs into hive tables but at this point I should just be using pig instead of hive to do my reporting.</p>