using JSON-SerDe in Hive tables

后端 未结 4 1311
被撕碎了的回忆
被撕碎了的回忆 2021-01-02 21:57

I\'m trying JSON-SerDe from below link http://code.google.com/p/hive-json-serde/wiki/GettingStarted.

         CREATE TABLE my_table (field1 string, field2          


        
4条回答
  •  爱一瞬间的悲伤
    2021-01-02 22:27

    A bit hard to tell what's going on without the logs (see Getting Started) in case of doubt. Just a quick thought - can you try if it works with WITH SERDEPROPERTIESas so:

    CREATE EXTERNAL TABLE my_table (field1 string, field2 int, 
                                    field3 string, field4 double)
    ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde'
    WITH SERDEPROPERTIES (
      "field1"="$.field1",
      "field2"="$.field2",
      "field3"="$.field3",
      "field4"="$.field4" 
    );
    

    There is also a fork you might want to give a try from ThinkBigAnalytics.

    UPDATE: Turns out the input in Test.json is invalid JSON hence the records get collapsed.

    See answer https://stackoverflow.com/a/11707993/396567 for further details.

提交回复
热议问题