Hive将二级分区表中指定分区的数据导入新表时遇到的问题及解决方案

问题描述:hive原始表old,二级分区分别是month,day,现在要求将指定分区下的所有数据导入一张新表new,new复制old表结构

create table new like old;

导入数据SQL语句

insert overwrite table new partition(month=10,day=01) select * from old where month='10' and day='01';

异常一:FAILED: SemanticException [Error 10044]: Line 1:23 Cannot insert into target table because column number/types are different ‘‘01’’: Table insclause-0 has 3 columns, but query has 5 columns.

错误原因:导入分区表时,只要写明分区字段名就行,不要写具体字段值partition(month=‘10’,day=‘01’) 错误
正确语句:

insert overwrite table new partition(month,day) select * from old where month='10' and day='01';

异常二:FAILED: SemanticException 1:23 Dynamic partition is disabled. Either enable it by setting hive.exec.dynamic.partition=true or specify partition column values. Error encountered near token ‘day’
错误原因:未开启动态分区

set hive.exec.dynamic.partition=true;//开启动态分区

异常三:FAILED: SemanticException [Error 10096]: Dynamic partition strict mode requires at least one static partition column. To turn this off set hive.exec.dynamic.partition.mode=nonstrict
错误原因:未关闭严格模式

set hive.exec.dynamic.partition.mode=nonstrict;//设置为非严格模式

备注:严格模式
Hive提供了一个严格模式,可以防止用户执行那些可能产生意想不到的不好的效果的查询。
如:

  1. 分区表的查询没有使用分区字段来限制。
  2. 使用了笛卡尔积
  3. order by 的时候没有使用limit
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值