Inserting into Hive table - Non Partitioned table to Partitioned table - Cannot insert into target table because column number/types

Viewed 25440

When I tried to insert into a Partiotioned table I am getting the bellow error SemanticException [Error 10044]: Line 1:23 Cannot insert into target table because column number/types are different ''US'': Table insclause-0 has 2 columns, but query has 3 columns.

My Input data

1,aaa,US
2,bbb,US
3,ccc,IN
4,ddd,US
5,eee,IN
6,fff,IN
7,ggg,US

Created hive table tx

create table tx (no int,name string,country string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';

Created Partitioned table t1 partitioned by country

create table t1 (no int,name string) PARTITIONED BY (country string)  ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';

I tried the bellow two insert, but failed

    INSERT OVERWRITE TABLE t1 PARTITION (country='US') 
SELECT *   from tx where country = 'US';

    INSERT OVERWRITE TABLE t1 PARTITION (country='US') 
SELECT no,name,country from tx where country = 'US';

Error : SemanticException [Error 10044]: Line 1:23 Cannot insert into target table because column number/types are different ''US'': Table insclause-0 has 2 columns, but query has 3 columns.

1 Answers
Related