Reputation: 91
I am trying to perform twitter analysis using hive but I am getting error as mentioned above. I already add the jar file as shown below and got no error in that, but while creating the external table I get the error as shown below:
FAILED: ParseException line 9:2 cannot recognize input near 'user' 'STRUCT' '<' in column name or primary key or foreign key
add jar /home/shashank/Desktop/Hadoopprac/Twitteranalysis/hive-json-serde.jar;
CREATE EXTERNAL TABLE IF NOT EXISTS tweets (
text STRING,
entities STRUCT<
hashtags:ARRAY<STRUCT<text:STRING>>>,
user STRUCT<
screen_name:STRING,
friends_count:INT,
followers_count:INT,
statuses_count:INT,
verified:BOOLEAN,
utc_offset:INT,
time_zone:STRING>
)
ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe'
LOCATION '/home/shashank/Desktop/Hadoopprac/tweetsfile.json';
Upvotes: 2
Views: 4465
Reputation: 91
so finally got the answer actually the issue is with the reserve keyword,the user is the reserve keyword in hive parsing so user should be put in `` and run the query thanks for effort by hlagos and cricket_007.
CREATE EXTERNAL TABLE IF NOT EXISTS tweets (
text STRING,
entities STRUCT<
hashtags:ARRAY<STRUCT<text:STRING>>>,
`user` STRUCT<
screen_name:STRING,
friends_count:INT,
followers_count:INT,
statuses_count:INT,
verified:BOOLEAN,
utc_offset:INT,
time_zone:STRING>
)
ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe'
LOCATION '/home/shashank/Desktop/Hadoopprac/tweetsfile.json';
Upvotes: 3