[英]Inserting into Hive table - Non Partitioned table to Partitioned table - Cannot insert into target table because column number/types
当我尝试插入分区表时,出现以下错误SemanticException [Error 10044]:行1:23无法插入目标表,因为列号/类型不同“ US”:表insclause-0有2列,但查询有3列。
我的输入数据
1,aaa,US
2,bbb,US
3,ccc,IN
4,ddd,US
5,eee,IN
6,fff,IN
7,ggg,US
创建蜂巢表TX
create table tx (no int,name string,country string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
创建按国家划分的分区表t1
create table t1 (no int,name string) PARTITIONED BY (country string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
我尝试了下面的两个插入物,但是失败了
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';
错误 :SemanticException [错误10044]:第1行:23无法插入目标表,因为列号/类型不同“ US”:表insclause-0有2列,但查询有3列。
非常感谢Samson Scharfrichter
INSERT OVERWRITE TABLE t1 PARTITION (country='US')
SELECT no,name from tx where country = 'US';
INSERT INTO TABLE t1 PARTITION (country='IN')
SELECT no,name from tx where country = 'IN';
我检查了分区
hive> SHOW PARTITIONS t1;
OK
country=IN
country=US
Time taken: 0.291 seconds, Fetched: 2 row(s)
hive>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.