Support Questions
Find answers, ask questions, and share your expertise

Json HIve clarification

Highlighted

Json HIve clarification

Contributor

i am trying json with hive using below link

http://thornydev.blogspot.in/2013/07/querying-json-records-via-hive.html

But i do not find any jar file in the link:-

https://github.com/rcongiu/Hive-JSON-Serde

5 REPLIES 5

Re: Json HIve clarification

Hi @vamsi valiveti. In order to get the jar you will need to build it using Maven.

1. Download and install Maven - https://maven.apache.org/. Make sure you add the bin directory to your PATH

2. Clone (download) rongiu's github and unzip.

3. Navigate to the directory with the pom.xml

4. Run the following command - mvn -Pcdh5 -Dcdh5.hive.version=1.0.0 clean package

5. You will find the jar in /json-serde/target

Keep in mind also that Hive comes with a native JSON Serde. https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-RowFormats&Ser...

Highlighted

Re: Json HIve clarification

Contributor

1)Thanks for inputs.I will try and let you know.

2)one more clarification how to get Collapsed version?If it is small json document means i will do it let us assume a big jsob document is present?How to get collapses version if source file is in below format.

{
    "DocId": "ABC",
    "User": {
        "Id": 1235,
        "Username": "fred1235",
        "Name": "Fred",
        "ShippingAddress": {
            "Address1": "456 Main St.",
            "Address2": "",
            "City": "Durham",
            "State": "NC"
        }
    }
}
 
{
    "DocId": "ABC",
    "User": {
        "Id": 1236,
        "Username": "larry1234",
        "Name": "Larry",
        "ShippingAddress": {
            "Address1": "789 Main St.",
            "Address2": "",
            "City": "Durham",
            "State": "NC",
            "PostalCode": "27713"
        },
        "Orders": [
            {
                "ItemId": 1111,
                "OrderDate": "11/11/2012"
            },
            {
                "ItemId": 2222,
                "OrderDate": "12/12/2012"
            }
        ]
    }
}

Collapsed version:

{"DocId":"ABC","User":{"Id":1235,"Username":"fred1235","Name":"Fred","ShippingAddress":{"Address1":"456 Main St.","Address2":"","City":"Durham","State":"NC"}}}
{"DocId":"ABC","User":{"Id":1236,"Username":"larry1234","Name":"Larry","ShippingAddress":{"Address1":"789 Main St.","Address2":"","City":"Durham","State":"NC","PostalCode":"27713"},"Orders":[{"ItemId":1111,"OrderDate":"11/11/2012"},{"ItemId":2222,"OrderDate":"12/12/2012"}]}

Highlighted

Re: Json HIve clarification

I use this http://www.jsoneditoronline.org/

Click on the icons on the upper-left corner to flatten it out.

Highlighted

Re: Json HIve clarification

Contributor

Hi @Scott Shaw.

1)I can get the to get Collapsed version using above url.It is working.Thanks but how we will do this in Prod environment.

This is manual work.Is there anyway to automate this?

2)Regarding https://github.com/rcongiu/Hive-JSON-Serde initially I do not see any target folder in json-serde,json-udf.

I ran all the steps as you mentioned previously.Now so many jar files are present in target directory of json-serde,json-udf.

Not sure which one i need to consider.Both screenshots are attached with this comment.Could you please guide me which jar file i need to use?Please correct me if i miss anything

json-serde-target:-

9302-json-serde-target.jpg

json-udf target:-

9303-json-udf-target.jpg

Highlighted

Re: Json HIve clarification

Contributor

Any Input on my request