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

Hive JSON Serde Key Value string:string hcatalog

Solved Go to solution

Hive JSON Serde Key Value string:string hcatalog

New Contributor

I am trying to query the following Json file:

{"a":"a1","b":"b1","d":"{"key1":"pair1","key2":"pair2"}"} 

I have created the following table to query it:

    CREATE EXTERNAL TABLE database.testingjson(
    	a STRING,
    	b STRING,
    	c STRING,
    	d map<string,string>
    )
    ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
    STORED AS TEXTFILE
    LOCATION 'location';

Shows the following exception:

    SQL Error: java.io.IOException: org.apache.hadoop.hive.serde2.SerDeException: java.io.IOException: Start of Object expected
      java.io.IOException: org.apache.hadoop.hive.serde2.SerDeException: java.io.IOException: Start of Object expected
        java.io.IOException: org.apache.hadoop.hive.serde2.SerDeException: java.io.IOException: Start of Object expected
          org.apache.hadoop.hive.serde2.SerDeException: java.io.IOException: Start of Object expected
            java.io.IOException: Start of Object expected
              java.io.IOException: Start of Object expected

If I delete the map from the table there is no problem and queries the data correctly. Is there anything that I'm missing? Or the hcatalog doesn't accept key value fields?

I'm using Hive 1.2

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Hive JSON Serde Key Value string:string hcatalog

Explorer

@Miguel Rodriguez

The JSON you are using isn't valid, you need to remove the double quotes around the map column value.

So your JSON would be:

{"a":"a1","b":"b1","d":{"key1":"pair1","key2":"pair2"}} 

View solution in original post

2 REPLIES 2

Re: Hive JSON Serde Key Value string:string hcatalog

Explorer

@Miguel Rodriguez

The JSON you are using isn't valid, you need to remove the double quotes around the map column value.

So your JSON would be:

{"a":"a1","b":"b1","d":{"key1":"pair1","key2":"pair2"}} 

View solution in original post

Re: Hive JSON Serde Key Value string:string hcatalog

New Contributor

Oh god, thank you.