1

I have a two tables emp1 and emp2 having fields-

  • userid
  • name
  • occupation
  • country

emp1 has partition on country and emp2 has partition on occupation

How can I move data from emp1 to emp2

Dev
  • 13,492
  • 19
  • 81
  • 174

1 Answers1

0

Overwrite target table with a dataset from emp1 plus (union all) old data that was in emp2 table. Note distribute by at the end of the query - this is for optimizing partitions creation, final reducers will receive only their partition data, this will reduce memory consumption.

insert overwrite table emp2 partition(occupation) 
select userid, name, country, occupation from emp1 
union all
select userid, name, country, occupation from emp2
distribute by occupation;

Additionally you may add removing duplicates using row_number().

leftjoin
  • 36,950
  • 8
  • 57
  • 116
  • Code only answers are not very useful on their own. It would help if you could add some detail explaining how/why it answers the question. – SiHa Sep 27 '16 at 15:20
  • Please edit your answer with explanation, or if you can't explain the code, please provide helpful link(s). You should avoid posting answers in fashion that satisfy questions "gimme code please". – xinaiz Sep 27 '16 at 16:58