title: Copying Hive managed table by copying partition directories into warehouse
body: <p>I have an existing bucketed table that has <code>YEAR, MONTH, DAY</code> partitioning, but I want to add additional partitioning by <code>INGESTION_KEY</code>, a column that doesn't exist in the existing table. This is to accommodate future table inserts so that I don't have to <code>OVERWRITE</code> a <code>YEAR, MONTH, DAY</code> partition every time I ingest data for that date; I can just do a simple <code>INSERT INTO</code> and create a new  <code>INGESTION_KEY</code> partition. </p>
  
  <p>I need a year's worth of data in my new table to start, so I want to copy a year of partitions from my existing table to a new table. Rather than doing a Hive <code>INSERT</code> for each partition, I thought it would be quicker to use <code>distcp</code> to copy files into the new table's partition directories in the Hive warehouse directory in HDFS, then <code>ADD PARTITION</code> to the new table.</p>
  
  <p>So, this is all I'm doing:</p>
  
  <pre><code>hadoop distcp /apps/hive/warehouse/src_db.db/src_tbl/year=2017/month=02/day=06 /apps/hive/warehouse/dest_db.db/dest_tbl/year=2017/month=02/day=06/ingestion_key=123
  
  hive -e "ALTER TABLE dest_tbl ADD PARTITION (year=2017,month=02,day=06,ingestion_key='123')"
  </code></pre>
  
  <p>Both are managed tables, the new table <code>dest_tbl</code> is clustered by the same column into the same number of buckets as the <code>src_tbl</code>, and the only difference in schema is the addition of <code>INGESTION_KEY</code>. </p>
  
  <p>So far my <code>SELECT * FROM dest_tbl</code> shows everything in the new table looking normal. So my question is: is there anything wrong with this approach? Is it bad to <code>INSERT</code> to a managed, bucketed table this way, or is this an acceptable alternative to <code>INSERT</code> if no transformations are being done on the copied data?</p>
  
  <p>Thanks!!</p>