如何在Hive中为此Json数据创建架构?

时间:2021-08-22 18:23:38

{
    "filter_level": "low",
    "retweeted": false,
    "in_reply_to_screen_name": "paperboatdrinks",
    "possibly_sensitive": false,
    "truncated": false,
    "lang": "und",
    "in_reply_to_status_id_str": "595491441440227328",
    "id": 595491657585299500,
    "in_reply_to_user_id_str": "1484637054",
    "timestamp_ms": "1430811249525",
    "in_reply_to_status_id": 595491441440227300,
    "created_at": "Tue May 05 07:34:09 +0000 2015",
    "favorite_count": 0,
    "place": null,
    "coordinates": null,
    "text": "@paperboatdrinks ������������������������������������",
    "contributors": null,
    "geo": null,
    "entities": {
        "trends": [],
        "symbols": [],
        "urls": [],
        "hashtags": [],
        "user_mentions": [
            {
                "id": 1484637054,
                "name": "Paper Boat",
                "indices": [
                    0,
                    16
                ],
                "screen_name": "paperboatdrinks",
                "id_str": "1484637054"
            }
        ]
    },
    "source": "Twitter for Android",
    "favorited": false,
    "in_reply_to_user_id": 1484637054,
    "retweet_count": 0,
    "id_str": "595491657585299456",
    "user": {
        "location": "",
        "default_profile": true,
        "statuses_count": 28,
        "profile_background_tile": false,
        "lang": "en",
        "profile_link_color": "0084B4",
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/3099469722/1429881891",
        "id": 3099469722,
        "following": null,
        "favourites_count": 2,
        "protected": false,
        "profile_text_color": "333333",
        "verified": false,
        "description": "3d visualizer",
        "contributors_enabled": false,
        "profile_sidebar_border_color": "C0DEED",
        "name": "VICKY GUSAIN",
        "profile_background_color": "C0DEED",
        "created_at": "Fri Mar 20 11:43:14 +0000 2015",
        "default_profile_image": false,
        "followers_count": 3,
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/591593652138344448/_JhM1YhS_normal.jpg",
        "geo_enabled": true,
        "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
        "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
        "follow_request_sent": null,
        "url": null,
        "utc_offset": null,
        "time_zone": null,
        "notifications": null,
        "profile_use_background_image": true,
        "friends_count": 9,
        "profile_sidebar_fill_color": "DDEEF6",
        "screen_name": "VickyHanumant",
        "id_str": "3099469722",
        "profile_image_url": "http://pbs.twimg.com/profile_images/591593652138344448/_JhM1YhS_normal.jpg",
        "listed_count": 0,
        "is_translator": false
    }
}`


But I had created schema but not accept it properly.

但我已经创建了架构,但没有正确接受它。



    create external table if not exists paper5 (
         filter_level  string,
         retweeted boolean,
         in_reply_to_screen_name string,
         possibly_sensitive boolean,
         truncated boolean,
         lang string,
         in_reply_to_status_id_str string,
         id int,
         in_reply_to_user_id_str string,
         timestamp_ms string,
         in_reply_to_status_id int,
         created_at string,
         favorite_count int,
         place string,
         coordinates string,
         text string,
         contributors string,
         geo string,
    entities struct,
    symbols: array,
    urls: array,
    hashtags: array,
    user_mentions: array>, screen_name: string, id_str: string>>,
          sources string,
          favorited boolean,
          in_reply_to_user_id int,
          retweet_count int,
          id_str string,
        user struct ) ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde' location '/paper5/';


It showing error at entities and user_mentions field Please let me know to create a table in hive.

它在entity和user_mentions字段显示错误请让我知道在hive中创建一个表。

1 个解决方案

#1


This link could help you it explains how you can insert data (json file) into hbase using hive QL with json_object

这个链接可以帮助你解释如何使用hive QL和json_object将数据(json文件)插入到hbase中

#1


This link could help you it explains how you can insert data (json file) into hbase using hive QL with json_object

这个链接可以帮助你解释如何使用hive QL和json_object将数据(json文件)插入到hbase中