Hive:无法将数据从未分区的 table 复制到分区的 table

Hive : Cannot copy data from unpartitioned table to partitioned table

我有一个未分区的 table

create table tabUn 
(
    col1 string,
    col2 int
)

假设它有一些数据。接下来我创建了一个分区 table

CREATE EXTERNAL TABLE tabPart 
(
    col1 string,
    col2 int
)
PARTITIONED BY (col_date string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
STORED AS TEXTFILE
LOCATION '/path/to/table';

最后,我尝试将数据复制过来

set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
INSERT OVERWRITE TABLE tabPart PARTITION(data_date='2018-10-01')
SELECT 
(
    col1,
    col2,
    '2018-10-01' as col_date
) select * FROM tabUn;

但我收到以下错误

FAILED: NullPointerException null

我做错了什么?

您的select陈述似乎不正确。

INSERT OVERWRITE TABLE tabPart PARTITION (data_date='2018-10-01')
SELECT col1,col2,'2018-10-01' as col_date from tabUn;