hive语句 partition(dt=substr('2016-12-01',1,7))取分区问题

今天帮助一个朋友排查hive语句的问题,如下:
insert overwrite table database.table
partition(dt=substr('2016-12-01',1,7))
select substr('2016-12-01',1,7) as month,...

报错:
cannot recognize input near 'substring' '(' ''2016-12-01'' in constant

问题出现partition(dt=substr('2016-12-01',1,7))这部分


执行这个查询语句没有问题
select substr('2016-12-01',1,7) as month,...

网上查找到:
for dynamic partitions the partition clause must look like
PARTITION(year, month, edate)
the actual expressions should be included in the select list. So in your
example the select list should look something like
SELECT sh.EVENT_TIME, sh.person_NAME, substring(event_time, 0, 4) as year,

解决方法:
insert overwrite table database.table
partition(dt)
select substr('2016-12-01',1,7) as dt,...

dt是分区的字段名称


参考:http://mail-archives.apache.org/mod_mbox/hive-user/201204.mbox/%3CCAOn+50K1LYvBN4LGz=CHDNeoqYAgg0f+uGA5bb2noH0VmidSsA@mail.gmail.com%3E

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值