gpt4 book ai didi

配置单元中的 Json 文件加载跳过第 1 行

转载 作者:行者123 更新时间:2023-12-02 22:03:32 25 4
gpt4 key购买 nike

我正在尝试使用 native 函数在配置单元中使用单个 JSON 数组文件,不知何故,当它加载到配置单元中时,第一行被转换为 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 解析器失败,从而导致返回 NULL 值。

关于配置单元中的 Json 文件加载跳过第 1 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43623023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com