빅데이터(BigData)/Hive

hive 테이블에 한번에 여러 파티션에 insert 하기

leebaro 2021. 2. 23.
728x90

아래와 같이 한 번의 쿼리로 여러 파티션이 데이터를 입력할 수 있다.

FROM table_name

INSERT OVERWRITE TABLE table_1 PARTITION (part_date = '20200101', cust_type = '1')

       select * where table_name.part_date = '20200101' and table_name.cust_type = '1'

INSERT OVERWRITE TABLE table_1 PARTITION (part_date = '20200101', cust_type = '2')

       select * where table_name.part_date = 'v' and table_name.cust_type = '2'

INSERT OVERWRITE TABLE table_1 PARTITION (part_date = '20200101', cust_type = '3')

       select * where table_name.part_date = '20200101' and table_name.cust_type = '3';

참고

sungwookkang.com/1452

728x90