jsonhadoophivehdfshive-serde

Unable to upload json file on hive using json serde


I am trying to load json file using json serde. I have added the serde jar file successfully.

1) My json jar file placed on path /apps/hive/warehouse/lib/ I have run this command successfully

add jar hdfs:///apps/hive/warehouse/lib/json-serde-1.3-jar-with-dependencies.jar; converting to local hdfs:///apps/hive/warehouse/lib/json-serde-1.3-jar-with-dependencies.jar Added [/tmp/6f1a54b9-65c4-4e32-8e87-25d60ef775c6_resources/json-serde-1.3-jar-with-dependencies.jar] to class path Added resources: [hdfs:///apps/hive/warehouse/lib/json-serde-1.3-jar-with-dependencies.jar] 

2) Now when i am trying to upload json file on this path /apps/hive/warehouse/lib/ or tmp/ using ambari GUI. I am unable to upload it gives error 500. see attached imageerror while uploading json file 3) I have also tried this command but beacuse i am unable to upload json file. so, it doesnot work

hadoop fs -put tmp/test.json /apps/hive/warehouse/lib/test.json

Kindly help me solving this issue


Solution

  • To load the file into hive, first copy the file to an HDFS Location. Like below:

    hadoop fs -put /complete_path_to_my_json/json_to_upload.json /app/hive/a_temp_location
    

    Then once you have the table created with JSON SerDe like below:

    create table if not exists my_json_table (id int, name string, designation string) row format serde 'org.apache.hive.hcatalog.d.JsonSerDe';
    

    You can load the data into the table with the following statement:

    load data inpath '/app/hive/a_temp_location/json_to_upload.json' into table my_json_table;