title: How to create partitions from one impala table to another
body: <p>I want to clone an impala table called 'blah' in our database for test purposes (so I don't accidentally delete something I shouldn't).  However, table 'blah' has partitions and it doesn't seem like the command I'm running is doing the trick.  Can someone tell me any tricks to have the partitions automatically created/mimicked in the new table or do I need to manually create the partitions in my new table?</p>
  
  <p>The cmd I'm using is:</p>
  
  <pre><code>CREATE TABLE blah_copy LIKE blah
  INSERT INTO TABLE blah_copy SELECT * FROM blah
  </code></pre>
  
  <p>It looks to create the table for me when I run because they have the same number of columns</p>
  
  <pre><code>desc blah
  desc blah_copy
  </code></pre>
  
  <p>However, when I try to copy the data (the insert statement above), it tells me </p>
  
  <pre><code>ERROR: AnalysisException: Not enough partition columns mentioned in query. Missing columns are: www, xxx, yyy, zzz.
  </code></pre>
  
  <p>Looking at the <a href="http://www.cloudera.com/documentation/archive/impala/2-x/2-0-x/topics/impala_create_table.html" rel="nofollow">cloudera documentation</a>, it says:</p>
  
  <blockquote>
    <p>If the original table is partitioned, the new table inherits the same
    partition key columns. Because the new table is initially empty, it
    does not inherit the actual partitions that exist in the original one.
    To create partitions in the new table, insert data or issue ALTER
    TABLE ... ADD PARTITION statements.</p>
  </blockquote>
  
  <p>So that's where I'm at right now.  Thanks in advance for any help you can give me.</p>