Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

hive table error

avatar
Super Collaborator

I created a hive table as follows :

CREATE EXTERNAL TABLE tweetdata(created_at STRING,
text STRING,
  person STRUCT< 
     screen_name:STRING,
     name:STRING,
     locations:STRING,
     description:STRING,
     created_at:STRING,
     followers_count:INT,
     url:STRING>
) ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe' location '/user/flume/tweets';

but I am getting errors doing selecting

iam using HDP2.5

hive>
    > describe tweetdata;
OK
created_at              string                  from deserializer
text                    string                  from deserializer
person                  struct<screen_name:string,name:string,locations:string,description:string,created_at:string,followers_count:int,url:string>   from deserializer
Time taken: 0.076 seconds, Fetched: 3 row(s)
hive> select person.name, text from tweetdata;
OK
Failed with exception java.io.IOException:org.apache.hadoop.hive.serde2.SerDeException: org.codehaus.jackson.JsonParseException: Unexpected character ('O' (code 79)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
 at [Source: java.io.StringReader@4668c5ea; line: 1, column: 2]
Time taken: 0.077 seconds
hive>
1 ACCEPTED SOLUTION

avatar
Super Collaborator

I fixed this error by using another serde "org.openx.data.jsonserde.JsonSerDe "

View solution in original post

2 REPLIES 2

avatar
Super Collaborator

I just created an empty simple table with no structures and its showing the same behavior .what am I missing here?

Logging initialized using configuration in file:/etc/hive/2.5.0.0-1245/0/hive-log4j.properties
hive> create external table load_tweets(id BIGINT,text STRING)
    >      ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
    >      LOCATION '/user/flume/tweets';
OK
Time taken: 1.003 seconds
hive> describe load_tweets;
OK
id                      bigint                  from deserializer
text                    string                  from deserializer
Time taken: 0.268 seconds, Fetched: 2 row(s)
hive>
    > ;
hive> select * from load_tweets;
OK
Failed with exception java.io.IOException:org.apache.hadoop.hive.serde2.SerDeException: org.codehaus.jackson.JsonParseException: Unexpected character ('O' (code 79)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
 at [Source: java.io.ByteArrayInputStream@5b8402e0; line: 1, column: 2]
Time taken: 1.386 seconds
hive>

avatar
Super Collaborator

I fixed this error by using another serde "org.openx.data.jsonserde.JsonSerDe "