JSON文件加载hive skipping row1



我正在尝试使用本机函数在Hive中使用单个JSON数组文件,以某种方式将其加载到Hive中时,第一行被转换为null,而丢失了第一行数据。请告知我做什么不正确?
数据:

[{"id":1,"first_name":"Alexandrina","email":"abalding0@goo.ne.jp","date":"9/11/2016","country":"Nigeria"},
{"id":2,"first_name":"Craggie","email":"ctremain1@photobucket.com","date":"12/7/2016","country":"China"},
{"id":3,"first_name":"Allie","email":"adearan2@ycombinator.com","date":"10/31/2016","country":"Russia"},
{"id":30,"first_name":"Vinson","email":"vplumbleyt@hubpages.com","date":"5/16/2016","country":"Saint Kitts and Nevis"}]

HIVE功能:

CREATE TABLE format.json_table (json string);
LOAD DATA INPATH  '/user/cloudera/JSON/MOCK_DATA.json' INTO TABLE json_table;


当我查询时:

select get_json_object(json_table.json, '$.id') as id,
get_json_object(json_table.json, '$.first_name') as name,
get_json_object(json_table.json, '$.email') as email,
get_json_object(json_table.json, '$.date') as date,
get_json_object(json_table.json, '$.country') as country from json_table;

它返回

OK
id  name    email   date    country
NULL    NULL    NULL    NULL    NULL
2   Craggie ctremain1@photobucket.com   12/7/2016   China
3   Allie   adearan2@ycombinator.com    10/31/2016  Russia
4   Poul    psondland3@mlb.com  9/11/2016   Nigeria
5   Vinson  vplumbleyt@hubpages.com 5/16/2016   Saint Kitts and Nevis

JSON SERDE与单行文档一起使用。
鉴于您的数据,适当地读取了有效的JSON文档本身的每一行,并且不会失败JSON解析器,从而导致零值返回。

相关内容

  • 没有找到相关文章

最新更新