Wednesday, November 12, 2014

How to process JSON data file using HIVE in Big Data

Use Hive-JSON SerDe

Copy hive-json-serde.jar to the Hive server

Copy test,json file into your folder.

ADD JAR /path/to/hive-json-serde.jar;

Create a table

       CREATE TABLE test_json_table (
          field1 string, field2 int, field3 string
       )
       ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde'
       LOAD DATA LOCAL INPATH '/tmp/test.json' INTO TABLE


Write a simple SELECT statement to fetch the data

SELECT field1,field2,field3 FROM test_json_table;

No comments:

Post a Comment