问题现象
生产环境 hive 往 es 表里 insert 数据时报空指针的错:NullPointerException StandardStructObjectInspector ObjectInspectorUtils.getStandardStructFieldRef,在 Google 搜了一圈 没有发现类似的报错。
hive es 表的建表语句如下: image.png版本信息
hive 1.2.1
es 6.4.3
相关代码与报错信息
sql 代码如下:
add jar hdfs:///user/hadoop/profile/elasticsearch-hadoop-hive-6.4.3.jar;
insert overwrite table adm.adm_es_video_metric_1d_delta_daily partition(dt = '${hiveconf:SRC_FILE_DAY}')
select
concat(content_id,program_id) as key
,content_id
,program_id
,sum(vv) as vv
,sum(cv) as cv
,sum(valid_vv) as valid_vv
,sum(play_duration_s) as play_duration_s
,sum(vvuv) as vvuv
,sum(cvuv) as cvuv
,sum(like_cnt) as like_cnt
,sum(share_cnt) as share_cnt
,sum(comment_cnt) as comment_cnt
,sum(recommend_cnt) as recommend_cnt
,'${hiveconf:SRC_FILE_DAY}' as dt1
from(
select
content_id
,program_id
,vv
,cv
,0 as valid_vv
,0 as play_duration_s
,vvuv
,cvuv
,0 as like_cnt
,0 as share_cnt
,0 as comment_cnt
,0 as recommend_cnt
from dws_video.dws_crystal_play_cnt_1d_delta_daily t1
where dt = '${hiveconf:SRC_FILE_DAY}' and group_id = '3'
) t5
where t5.content_id <> '-998' and t5.program_id rlike '^[0-9]{9}$'
group by content_id,program_id
;
报错信息如下:
image.png
问题解决
es.resource = video_metric_{dt}/default 配置错误
{dt} 改成 {dt1} 即可,${dt1} 才是 es 表的 field name
dt 是分区字段 es.resource 支持分区参数只支持 field name ,当前版本不支持分区字段;
定位过程
resource 改成静态路径,写入的 mapping 如下:里面无 dt 字段
image.png
经测试,mapping 无法使用分区字段,即使 mapping 里指定
image.png
网友评论