title: Failed with exception java.io.IOException:org.apache.avro.AvroTypeException: Found long, expecting union in hive
body: <p>Need help!!!</p>
  
  <p>I am streaming twitter feeds into hdfs using <code>flume</code> and loading it up in <code>hive</code> for analysis.</p>
  
  <p>The steps are as follows:</p>
  
  <p>Data in <a href="http://i.stack.imgur.com/cAUA5.png" rel="noreferrer">hdfs</a>:</p>
  
  <p>I have described the <code>avro schema</code> in an <code>avsc</code> file and put it in hadoop:</p>
  
  <pre><code> {"type":"record",
   "name":"Doc",
   "doc":"adoc",
   "fields":[{"name":"id","type":"string"},
         {"name":"user_friends_count","type":["int","null"]},
         {"name":"user_location","type":["string","null"]},
         {"name":"user_description","type":["string","null"]},
         {"name":"user_statuses_count","type":["int","null"]},
         {"name":"user_followers_count","type":["int","null"]},
         {"name":"user_name","type":["string","null"]},
         {"name":"user_screen_name","type":["string","null"]},
         {"name":"created_at","type":["string","null"]},
         {"name":"text","type":["string","null"]},
         {"name":"retweet_count","type":["boolean","null"]},
         {"name":"retweeted","type":["boolean","null"]},
         {"name":"in_reply_to_user_id","type":["long","null"]},
         {"name":"source","type":["string","null"]},
         {"name":"in_reply_to_status_id","type":["long","null"]},
         {"name":"media_url_https","type":["string","null"]},
         {"name":"expanded_url","type":["string","null"]}]}
  </code></pre>
  
  <p>I have written an .hql file to create a table and loaded data in it:</p>
  
  <pre><code> create table tweetsavro
      row format serde
          'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
      stored as inputformat
          'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
      outputformat
          'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
      tblproperties ('avro.schema.url'='hdfs:///avro_schema/AvroSchemaFile.avsc');
  
      load data inpath '/test/twitter_data/FlumeData.*' overwrite into table tweetsavro;
  </code></pre>
  
  <p>I have successfully run the .hql file but when i run the <code>select *from &lt;tablename&gt;</code> command in hive it shows the following error:</p>
  
  <p><a href="http://i.stack.imgur.com/b0aPw.png" rel="noreferrer">error</a></p>
  
  <p>The output of tweetsavro is:</p>
  
  <pre><code>hive&gt; desc tweetsavro;
  OK
  id                      string                                      
  user_friends_count      int                                         
  user_location           string                                      
  user_description        string                                      
  user_statuses_count     int                                         
  user_followers_count    int                                         
  user_name               string                                      
  user_screen_name        string                                      
  created_at              string                                      
  text                    string                                      
  retweet_count           boolean                                     
  retweeted               boolean                                     
  in_reply_to_user_id     bigint                                      
  source                  string                                      
  in_reply_to_status_id   bigint                                      
  media_url_https         string                                      
  expanded_url            string                                      
  Time taken: 0.697 seconds, Fetched: 17 row(s)
  </code></pre>