簡體   English   中英

使用Hive在數組中創建結構

[英]Creating structs in an array using Hive

我正在蜂巢中為Twitter json文件創建表。這是示例文件。 我面臨的問題是我無法使用結構創建數組,因為在以下數據中,單個數組中有4個相同的結構。 誰能告訴我如何為以下數據創建數組。 我嘗試給每個結構指定不同的名稱,該表已成功創建,但無法從table.Kindly Help中提取數據。 謝謝

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

嘗試這個,

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獲取Serde

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM