2

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';
4
  • hive version? sintax seems to be correct Commented Apr 24, 2018 at 12:47
  • I'm confused why hashtags is not just an array of strings Commented Apr 25, 2018 at 1:22
  • Hive version : hive-2.3.2 Commented Apr 25, 2018 at 17:35
  • Because I need the hashtag text too for knowing the popularity of tweet. Commented Apr 25, 2018 at 17:37

1 Answer 1

3

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';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.