hivehive-partitions

Hive insert into partitioned table with colums list from select


I want to insert into a partitioned Hive table tb_1(a, b, c, d, p1) only columns (a, b) from a select statement. Ex: insert into table tb_1 partition (p1) (a, b) select a, b from tb_2;

How can I achieve this?


Solution

  • correct SQL should be -

    insert into table tb_1 partition (p1) (a, b, p1) select a, b,p1 from tb_2;
    

    You need to add p1 in the insert list and select list.