Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Creating a HIVE table with structs inside structs with org.apache.hcatalog.data.JsonSerDe

Solved Go to solution

Creating a HIVE table with structs inside structs with org.apache.hcatalog.data.JsonSerDe

New Contributor

I'm trying to create a hive external table using org.apache.hcatalog.data.JsonSerDe library based on this example https://community.hortonworks.com/questions/28684/creating-a-hive-table-with-orgapachehcatalogdatajs.... The thing is that when I try with a very simple json structure it works fine but when I try with a more complex one (such as having a struct inside a struct attribute) I get the org.apache.hive.service.cli.HiveSQLException: java.io.IOException: org.apache.hadoop.hive.serde2.SerDeException: java.io.IOException: Start of Object expected error when I do a simple query.

Data Example:

{ "user": { "userlocation": "California, Santa Clara", "id": 222222, "name": "Hortonworks", "screenname": "hortonworks", "geoenabled": true, "location":[{"x":-88.083131,"y":99.984982},{"x":-88.083131,"y":99.984982}] }, "tweetmessage": "Learn more about #Spark in #HDP 2.3 with @Hortonworks founder @acmurthy in this video overview http://bit.ly/1gOyr9w #hadoop", "createddate": "2015-07-24T16:30:33"}

Query:

CREATE EXTERNAL TABLE tweets ( createddate string, geolocation string, tweetmessage string, `user` struct<geoenabled:boolean, id:int, name:string, screenname:string, userlocation:string, location:struct<x: double, y: double>>) ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe' LOCATION '/user/root/';

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Creating a HIVE table with structs inside structs with org.apache.hcatalog.data.JsonSerDe

Rising Star

I guess there are some errors in your DDL. The first one I can see is that location should be:

array<struct<x: double, y: double>>

Please try with this change and see whether it works or there are other problems.

View solution in original post

2 REPLIES 2
Highlighted

Re: Creating a HIVE table with structs inside structs with org.apache.hcatalog.data.JsonSerDe

Rising Star

I guess there are some errors in your DDL. The first one I can see is that location should be:

array<struct<x: double, y: double>>

Please try with this change and see whether it works or there are other problems.

View solution in original post

Highlighted

Re: Creating a HIVE table with structs inside structs with org.apache.hcatalog.data.JsonSerDe

New Contributor

Thanks a lot. That worked.

Don't have an account?
Coming from Hortonworks? Activate your account here