2011-08-08 62 views
0

我有一個包含json記錄的文本文件,我想將其加載到Hive。我的JSON的樣子:Hive開箱即用json解析器

{"vr":1,"tm":1312816191516,"tms":"08-08-2011 15:09:51.516 GMT","as":1002,"pb":1102,"cts":[1204,1205],"ctgs":[1304,1305],"op":1400,"ev":2,"dv":1503,"dvgs":[1605,1606],"cnt":"cnt5","usr":"usr8","atts":[{"id":8002,"val":"ccc"},{"id":8003,"val":"ddd"}],"sel":{"cm":2102,"ty":"PRE","ag":3002,"ad":4002,"fl":5002,"fla":6002,"hg":7002,"mc":"WAP","pr":0.1}} 

正如你可以看到我有原語和對象數組的數組的嵌套JSON。

是否可以使用任何內置函數將它原樣加載到Hive?

Yosi

回答

1

也會檢出brickhouse - https://github.com/klout/brickhouse。 他們有相當體面的用於json的UDF(如json_split和json_map)。 使用brickhouse和get_json_object/json_tuple(這裏也提到了Nija),您甚至可以避免使用自定義SerDe,如Hive-JSON-Serde。