2016-07-23 62 views
0

我已經編寫了以下配置單元查詢。這裏我試圖在我的連接子句中使用Map數據類型的列(msg)。使用映射數據類型的Hive查詢失敗

select p.p_id, count(*) from prod_json n 
inner join res_pan p on n.msg["mid"] = p.id 
where n.cat='XYX' 
group by p.p_id limit 10; 

此查詢總是失敗,錯誤消息

[Error getting row data with exception java.lang.ClassCastException: 
java.lang.String cannot be cast to org.openx.data.jsonserde.json.JSONObject at 
org.openx.data.jsonserde.objectinspector.JsonMapObjectInspector.getMap(Json 
MapObjectInspector.java:40) at 
org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:317) at 
org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:353) at 
org.apache.hadoop.hive.serde2.SerDeUtils.getJSONString(SerDeUtils.java:197) at 
org.apache.hadoop.hive.serde2.SerDeUtils.getJSONString(SerDeUtils.java:183) at 
org.apache.hadoop.hive.ql.exec.MapOperator.toErrorMessage(MapOperator.java: 
529) at 
org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:502) at 
org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:170) at 
org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54) at 
org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:453) at 

回答

0

我想我是能夠解決的問題。我重新寫我的查詢作爲

select t2.p_id, count(*) 
from (select cat, msg["mid"] as mid from prod_json) t1 
join (select id, p_id from res_pan) t2 
on t1.mid = t2.id 
where t1.cat = 'XYZ' 
group by t2.p_id 

所以基本上不要試圖直接,但首先使用內部查詢使用地圖列platten地圖爲列,然後在這些加入。

相關問題