首页 » 大数据 » 正文

[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';

发表评论

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax