使用配置单元在数组中创建结构

yk9xbfzb  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(393)

我正在配置单元中为twitterjson文件创建表。我面临的问题是,我无法用struct创建数组,因为在下面的数据中,单个数组中有4个相同的struct。谁能告诉我如何为下面的数据创建数组。我尝试给每个结构赋予不同的名称,表创建成功,但无法从表中提取数据。请帮助。谢谢

> "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"
         }
       ]
zi8p0yeb

zi8p0yeb1#

试试这个,

CREATE TABLE complex_json (
  variants:array<struct<bitrate:int,content_type:string, url:string>>>
)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe';

把塞德从https://github.com/rcongiu/hive-json-serde

相关问题