【问题标题】:Hive create table : parse error missing ">" while parsing json fileHive 创建表:解析 json 文件时解析错误缺少“>”
【发布时间】:2014-08-24 23:45:28
【问题描述】:

我在创建 hive 表时遇到以下异常。谁能指出我的错误? 示例输入:{"user":{"userlocation":"Bolton, UK","id":14141159,"name":"Chris Beckett","screenname":"ChrisBeckett","geoenabled":true}," tweetmessage":"vCOps 人 - 高级版 == 5 个 VM?我知道 Std 有 UI 和分析 VM,但其余的使用什么?Hyperic 等?#vmware #vcops","createddate":"2013-06-20T12: 08:46","地理位置":null}

enter code here

   CREATE EXTERNAL TABLE IF NOT EXISTS twitter(
   users map<string,string,string,string,string>,
   message string,
    createddate string,
    geolocation string
  )
    ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde'
  LOCATION ' /user/root/hadoop_tests/sample_twitter_data.txt';

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:212)

FAILED: ParseException line 2:23 missing > at ',' near 'string' in column type 第 2:30 行无法识别列类型中 ',' 'string' ',' 附近的输入

【问题讨论】:

    标签: json hive


    【解决方案1】:

    也许你应该使用 Struct 而不是 Map.Below:

    CREATE EXTERNAL TABLE IF NOT EXISTS twitter(
       users  struct<userlocation:string,id:string,name:string,screenname:string,geoenabled:string>,
       message string,
       createddate string,
       geolocation string
    )
    ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde'
    LOCATION '/user/root/hadoop_tests/';  
    

    【讨论】:

    • 是的,意识到我应该使用结构。我进行了更改,但由于某种原因,数据被加载为 Null。只有 createddate 字段被选中。所有其他列数据为空。任何想法
    猜你喜欢
    • 1970-01-01
    • 2018-12-11
    • 2014-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 2020-08-09
    • 1970-01-01
    相关资源
    最近更新 更多