赞
踩
执行hive sql时遇到问题:
FAILED:Execution Error,return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
这个其实一般是个hive内部错误,处理这个问题就需要找日志了;
找日志
set hive.exec.mode.local.auto=false
#!/bin/bash
source /etc/profile
if [ -n "$1" ] ;then
do_date=$1
else
do_date=`date -d "-1 day" +%F`
fi
sql="
insert overwrite table dws.dws_member_retention_day partition(dt='$do_date')
(
select
t2.device_id,
t2.uid,
t2.app_v,
t2.os_type,
t2.language,
t2.channel,
t2.area,
t2.brand,
t2.dt add_date,
1
from
dws.dws_member_start_day t1
join
dws.dws_member_add_day t2
on
t1.device_id=t2.device_id
where
t2.dt=date_add('$do_date',-1)
and
t1.dt='$do_date'
union all
select
t2.device_id,
t2.uid,
t2.app_v,
t2.os_type,
t2.language,
t2.channel,
t2.area,
t2.brand,
t2.dt add_date,
2
from
dws.dws_member_start_day t1
join
dws.dws_member_add_day t2
on
t1.device_id=t2.device_id
where
t2.dt=date_add('$do_date',-2)
and
t1.dt='$do_date'
union all
select
t2.device_id,
t2.uid,
t2.app_v,
t2.os_type,
t2.language,
t2.channel,
t2.area,
t2.brand,
t2.dt add_date,
3
from
dws.dws_member_start_day t1
join
dws.dws_member_add_day t2
on
t1.device_id=t2.device_id
where
t2.dt=date_add('$do_date',-3)
and
t1.dt='$do_date'
);
"
hive -e "$sql"
改动sql之后执行成功:(我这里是写在脚本中的sql)
#!/bin/bash
source /etc/profile
if [ -n "$1" ] ;then
do_date=$1
else
do_date=`date -d "-1 day" +%F`
fi
sql="
create table tmp.tmp_member_retention as
(
select
t2.device_id,
t2.uid,
t2.app_v,
t2.os_type,
t2.language,
t2.channel,
t2.area,
t2.brand,
t2.dt add_date,
1
from
dws.dws_member_start_day t1
join
dws.dws_member_add_day t2
on
t1.device_id=t2.device_id
where
t2.dt=date_add('$do_date',-1)
and
t1.dt='$do_date'
union all
select
t2.device_id,
t2.uid,
t2.app_v,
t2.os_type,
t2.language,
t2.channel,
t2.area,
t2.brand,
t2.dt add_date,
2
from
dws.dws_member_start_day t1
join
dws.dws_member_add_day t2
on
t1.device_id=t2.device_id
where
t2.dt=date_add('$do_date',-2)
and
t1.dt='$do_date'
union all
select
t2.device_id,
t2.uid,
t2.app_v,
t2.os_type,
t2.language,
t2.channel,
t2.area,
t2.brand,
t2.dt add_date,
3
from
dws.dws_member_start_day t1
join
dws.dws_member_add_day t2
on
t1.device_id=t2.device_id
where
t2.dt=date_add('$do_date',-3)
and
t1.dt='$do_date'
);
insert overwrite table dws.dws_member_retention_day partition(dt='$do_date')
select * from tmp.tmp_member_retention;
"
hive -e "$sql"
其实sql改动不大,无非是,改动后的是,创建一个临时表,在插入到对应的表中
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。