使用动态分区将记录插入到名为exam_51_final
的表中时遇到问题,这是我的情况:
create table exam_51_temp(
order_id int,
order_date bigint,
order_customer_id int,
order_status string)
stored as avro
TBLPROPERTIES ('avro.schema.url'='/user/ccp/20180827/51/avro.schema');
当我打印输出时,我有:
68878 1404770400000 6753 COMPLETE COMPLETE
68879 1404856800000 778 COMPLETE COMPLETE
68880 1405202400000 1117 COMPLETE COMPLETE
然后我以如下方式创建表exam_51_final
:
create table exam_51_final(
order_id int,
order_date bigint,
order_customer_id int,
order_status string)
partitioned by (order_month string)
stored as avro;
我使用以下方法激活动态分区:
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
然后,我最终尝试通过两种方式将记录从exam_51_temp
插入到exam_51_final
,以模拟虚拟动态分区列:
1)
insert into table exam_51_final partition(order_m)
select order_id,order_date,order_customer_id,order_status,(case
when order_id < 1000 then '2018-05'
when order_id >= 1000 then '2018-06'
end) order_m
from exam_51_temp;
2)
insert into table exam_51_final partition(order_m)
select order_id,order_date,order_customer_id,order_status, order_status as order_m
from exam_51_temp;
select查询本身进行得很好,但是我总是收到以下错误消息:
FAILED: SemanticException Partition spec {order_m=null} contains non-partition columns
我的错误在哪里?
答案 0 :(得分:0)
抱歉,我找到了解决方案:分区列名称必须为order_month,如果我输入其他列名称,则会收到上述错误。