2016-07-22 4 views
0

最初に、私はHiveを初めて使用しています。HIVEテーブルの作成中にJSON構文解析エラーが発生する

私はApacheのflumeでTwitterデータを取得しました。

{ 
"filter_level": "low", 
"retweeted": false, 
"in_reply_to_screen_name": null, 
"possibly_sensitive": false, 
"truncated": false, 
"lang": "en", 
"in_reply_to_status_id_str": null, 
"id": 756378998838530048, 
"in_reply_to_user_id_str": null, 
"timestamp_ms": "1469169780822", 
"in_reply_to_status_id": null, 
"created_at": "Fri Jul 22 06:43:00 +0000 2016", 
"favorite_count": 0, 
"place": null, 
"coordinates": null, 
"text": "#furry pokemon sex mermaid sex position", 
"contributors": null, 
"geo": null, 
"entities": { 
    "symbols": [], 
    "urls": [{ 
     "expanded_url": "http://14.gerase.tk", 
     "indices": [40, 63], 
     "display_url": "14.gerase.tk", 
     "url": "" 
    }], 
    "hashtags": [{ 
     "text": "furry", 
     "indices": [0, 6] 
    }], 
    "user_mentions": [] 
}, 
"is_quote_status": false, 
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client<\/a>", 
"favorited": false, 
"in_reply_to_user_id": null, 
"retweet_count": 0, 
"id_str": "756378998838530048", 
"user": { 
    "location": null, 
    "default_profile": true, 
    "statuses_count": 3436, 
    "profile_background_tile": false, 
    "lang": "ru", 
    "profile_link_color": "2B7BB9", 
    "id": 752318303280955392, 
    "following": null, 
    "favourites_count": 0, 
    "protected": false, 
    "profile_text_color": "333333", 
    "verified": false, 
    "description": null, 
    "contributors_enabled": false, 
    "profile_sidebar_border_color": "C0DEED", 
    "name": "Мария Виноградова", 
    "profile_background_color": "F5F8FA", 
    "created_at": "Mon Jul 11 01:47:15 +0000 2016", 
    "default_profile_image": false, 
    "followers_count": 5, 
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/753398763201425408/X_2mAGt1_normal.jpg", 
    "geo_enabled": false, 
    "profile_background_image_url": "", 
    "profile_background_image_url_https": "", 
    "follow_request_sent": null, 
    "url": null, 
    "utc_offset": null, 
    "time_zone": null, 
    "notifications": null, 
    "profile_use_background_image": true, 
    "friends_count": 21, 
    "profile_sidebar_fill_color": "DDEEF6", 
    "screen_name": "afinafedorova2", 
    "id_str": "752318303280955392", 
    "profile_image_url": "http://pbs.twimg.com/profile_images/753398763201425408/X_2mAGt1_normal.jpg", 
    "listed_count": 5, 
    "is_translator": false 
} 

}

https://github.com/cloudera/cdh-twitter-example で述べたように、私はHiveJSONSerDeを使用していますが、これは私が実行しようとしているハイブクエリです。

create external table twitterdata(
filter_level string, 
retweeted boolean, 
in_reply_to_screen_name string, 
possibly_sensitive boolean, 
trauncated boolean, 
lang string, 
in_reply_to_status_id_str string, 
id bigint, 
in_reply_to_user_id_str string, 
timestamp_ms string, 
in_reply_to_status_id int, 
created_at string, 
favourite_count int, 
place string, 
coordinates string, 
text string, 
contributors string, 
geo string, 
entities STRUCT< 
     urls:ARRAY<STRUCT<expanded_url:STRING,url:STRING>>, 
    hashtags:ARRAY<STRUCT<text:STRING>>, 
     user_mentions:ARRAY<STRUCT<screen_name:STRING,name:STRING>>>, 
is_quote_status boolean, 
source string, 
favotited boolean, 
in_reply_to_user_id int, 
retweet_count int, 
id_str string, 
user STRUCT< 
    location:STRING, 
    default_profile:boolean, 
    statuses_count:int, 
    profile_background_tile:boolean, 
    lang: string, 
    profile_link_color: string, 
    id: bigint, 
    following: string, 
    protected: boolean, 
    profile_text_color: string, 
    verified: boolean, 
    description: string, 
    contributors_enabled: boolean, 
    name: string, 
    created_at: string, 
    default_profile_image: boolean, 
    followers_count: int, 
    profile_image_url_https: string, 
    geo_enabled: boolean 
    url: string, 
    time_zone: string, 
    friends_count: int, 
    screen_name: string, 
    id_str: string, 
    listed_count: int, 
    is_translator: boolean> 
) 
ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe' 
STORED AS TEXTFILE 
LOCATION '/Twitter/Pokemon/'; 

しかし、JSONスクリプトの解析に関するエラーが表示されています。

FAILED: Parse Error: line 31:2 mismatched input 'location' expecting identifier in column specification 

私はcreate tableクエリで間違いを見つけることができません。助けてください。

答えて

0

データファイルのその行を調べることができます。 JSONファイルが損なわれていないか、スキーマと一致していない可能性が最も高いです。

ハイブテーブルに継続的にデータをロードする場合は、StreamSetsもチェックしてください。これを使用してJSONデータをキャプチャし、自動的にAvroに変換し、ハイブテーブルを作成し更新することができます。

私はプロジェクトのコミッタです。

+1

実際、「場所」自体はハイブ内のキーワードであり、属性名として使用することはできません。申し訳ありませんが、私は質問を編集するのを忘れました。 :) – Bihan

関連する問題