首页 » 大数据 » 正文

[Hive]Need to specify partition columns because the destination table is partition

当向已经分区的表插入数据时,有可能会报错:

Need to specify partition columns because the destination table is partition

原因是需要在插入的数据中指定分区字段的数值是多少。

比如:

建表语句:

create table test (
starttime string,
endtime string,
title string
)
PARTITIONED BY (username string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '| '
STORED AS TEXTFILE;</p>

<p>create table test2 (
starttime string,
endtime string,
title string
)
PARTITIONED BY (username string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '| '
STORED AS TEXTFILE;

插入语句:

insert into table test PARTITION(username='admin') select starttime, endtime, title from test2 where username = 'admin';

发表评论