蜂巢:无法将数据从未分区表复制到分区表

时间:2018-10-01 20:39:59

标签: hive hql hiveql

我有一个未分区的表

create table tabUn 
(
    col1 string,
    col2 int
)

可以说它有一些数据。接下来,我创建了一个分区表

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;

但出现以下错误

  

失败:NullPointerException为空

我在做什么错了?

1 个答案:

答案 0 :(得分:1)

您的选择语句似乎不正确。

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