Hive批量插入分区表时报java.lang.ClassCastException解决办法

将从一个表查询结果插入到一个分区表时,有时会在Load data步骤出错,这是在执行语句前没切换到目标表所在的库导致。

所以在执行插入语句前,先用use databasename切换到目标表所在的库下就正常了。

——————————以下是出错语句示例————————————

$ hive
Logging initialized using configuration in jar:file:/data/opt/hive-0.8.1/lib/hive-common-0.8.1.jar!/hive-log4j.properties
Hive history file=/tmp/hadoop/hive_job_log_hadoop_201302171019_1202642080.txt

hive> INSERT OVERWRITE TABLE dw1.t_test PARTITION(f_day)
    >     SELECT f_prod_id, f_uuid_prod, f_uuid_channel, f_uuid, f_cost, f_day
    >     FROM dw0.t_test
    >     WHERE f_day >= '2013-02-02' and f_day<= '2013-02-03'
    >     DISTRIBUTE BY f_day;
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks not specified. Estimated from input data size: 1
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapred.reduce.tasks=<number>
Starting Job = job_201206261006_347586, Tracking URL = http://master:50030/jobdetails.jsp?jobid=job_201206261006_347586
Kill Command = /data/opt/hadoop/bin/hadoop job  -Dmapred.job.tracker=master:9001 -kill job_201206261006_347586
Hadoop job information for Stage-1: number of mappers: 13; number of reducers: 1
2013-02-17 14:03:37,377 Stage-1 map = 0%,  reduce = 0%
2013-02-17 14:03:39,396 Stage-1 map = 8%,  reduce = 0%, Cumulative CPU 1.21 sec
2013-02-17 14:03:40,405 Stage-1 map = 54%,  reduce = 0%, Cumulative CPU 12.34 sec
2013-02-17 14:03:41,412 Stage-1 map = 92%,  reduce = 0%, Cumulative CPU 26.6 sec
2013-02-17 14:03:42,419 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 29.29 sec
2013-02-17 14:03:43,426 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 29.29 sec
2013-02-17 14:03:44,433 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 29.29 sec
2013-02-17 14:03:45,440 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 29.29 sec
2013-02-17 14:03:46,447 Stage-1 map = 100%,  reduce = 33%, Cumulative CPU 29.29 sec
2013-02-17 14:03:47,455 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 31.7 sec
2013-02-17 14:03:48,462 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 31.7 sec
MapReduce Total cumulative CPU time: 31 seconds 700 msec
Ended Job = job_201206261006_347586
Loading data to table dw1.t_test partition (f_day=null)
Deleted hdfs://master/data/dw1/test/f_day=20130202
Failed with exception java.lang.ClassCastException: org.apache.hadoop.hive.metastore.api.InvalidOperationException cannot be cast to java.lang.RuntimeException
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask
MapReduce Jobs Launched:
Job 0: Map: 13  Reduce: 1   Accumulative CPU: 31.7 sec   HDFS Read: 71311348 HDFS Write: 14213 SUCESS
Total MapReduce CPU Time Spent: 31 seconds 700 msec

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值