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
I have a two tables emp1
and emp2
having fields-
emp1
has partition on country and emp2
has partition on occupation
How can I move data from emp1
to emp2
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().