我正在hive中为twitter json文件创建表。这是示例文件。我面临的问题是我无法使用struct创建数组,因为在下面的数据中,单个数组中有4个相同的结构。任何人都可以告诉我如何为下面的数据创建数组。我试过给每个结构不同的名称,表创建成功但我无法从表中提取数据。求助。 感谢
> "variants": [
{
"bitrate": 2176000,
"content_type": "video\/mp4",
"url": "https:\/\/video.twimg.com\/ext_tw_video\/560070131976392705\/pu\/vid\/1280x720\/c4E56sl91ZB7cpYi.mp4"
},
{
"bitrate": 320000,
"content_type": "video\/mp4",
"url": "https:\/\/video.twimg.com\/ext_tw_video\/560070131976392705\/pu\/vid\/320x180\/nXXsvs7vOhcMivwl.mp4"
},
{
"bitrate": 832000,
"content_type": "video\/webm",
"url": "https:\/\/video.twimg.com\/ext_tw_video\/560070131976392705\/pu\/vid\/640x360\/vmLr5JlVs2kBLrXS.webm"
},
{
"bitrate": 832000,
"content_type": "video\/mp4",
"url": "https:\/\/video.twimg.com\/ext_tw_video\/560070131976392705\/pu\/vid\/640x360\/vmLr5JlVs2kBLrXS.mp4"
},
{
"content_type": "application\/x-mpegURL",
"url": "https:\/\/video.twimg.com\/ext_tw_video\/560070131976392705\/pu\/pl\/r1kgzh5PmLgium3-.m3u8"
}
]
答案 0 :(得分:0)
试试这个,
CREATE TABLE complex_json (
variants:array<struct<bitrate:int,content_type:string, url:string>>>
)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe';
获取serde